Skip to content

Commit efb9933

Browse files
committed
Start porting request templates (etc) from HTTPlease
#166
1 parent ad82d02 commit efb9933

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+6232
-59
lines changed
+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
using System;
2+
3+
namespace KubeClient.Http
4+
{
5+
/// <summary>
6+
/// Extension methods for <see cref="HttpRequestFactory"/>.
7+
/// </summary>
8+
public static class FactoryExtensions
9+
{
10+
/// <summary>
11+
/// Create a new HTTP request with the specified request URI.
12+
/// </summary>
13+
/// <param name="requestFactory">
14+
/// The HTTP request factory.
15+
/// </param>
16+
/// <param name="requestUri">
17+
/// The request URI (can be relative or absolute).
18+
/// </param>
19+
/// <returns>
20+
/// The new <see cref="HttpRequest"/>.
21+
/// </returns>
22+
public static HttpRequest Create(this HttpRequestFactory requestFactory, string requestUri)
23+
{
24+
if (requestFactory == null)
25+
throw new ArgumentNullException(nameof(requestFactory));
26+
27+
if (String.IsNullOrWhiteSpace(requestUri))
28+
throw new ArgumentException("Argument cannot be null, empty, or composed entirely of whitespace: 'requestUri'.", nameof(requestUri));
29+
30+
return requestFactory.Create(
31+
new Uri(requestUri, UriKind.RelativeOrAbsolute)
32+
);
33+
}
34+
}
35+
}

0 commit comments

Comments
 (0)