Skip to content

Commit

Permalink
Start porting request templates (etc) from HTTPlease
Browse files Browse the repository at this point in the history
  • Loading branch information
tintoy committed Dec 5, 2024
1 parent ad82d02 commit efb9933
Show file tree
Hide file tree
Showing 52 changed files with 6,232 additions and 59 deletions.
35 changes: 35 additions & 0 deletions src/KubeClient/Http/FactoryExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using System;

namespace KubeClient.Http
{
/// <summary>
/// Extension methods for <see cref="HttpRequestFactory"/>.
/// </summary>
public static class FactoryExtensions
{
/// <summary>
/// Create a new HTTP request with the specified request URI.
/// </summary>
/// <param name="requestFactory">
/// The HTTP request factory.
/// </param>
/// <param name="requestUri">
/// The request URI (can be relative or absolute).
/// </param>
/// <returns>
/// The new <see cref="HttpRequest"/>.
/// </returns>
public static HttpRequest Create(this HttpRequestFactory requestFactory, string requestUri)
{
if (requestFactory == null)
throw new ArgumentNullException(nameof(requestFactory));

if (String.IsNullOrWhiteSpace(requestUri))
throw new ArgumentException("Argument cannot be null, empty, or composed entirely of whitespace: 'requestUri'.", nameof(requestUri));

return requestFactory.Create(
new Uri(requestUri, UriKind.RelativeOrAbsolute)
);
}
}
}
Loading

0 comments on commit efb9933

Please sign in to comment.