-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tidy up logging code for Watch streams
- Loading branch information
Showing
3 changed files
with
82 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
using HTTPlease; | ||
using HTTPlease.Core; | ||
using System; | ||
using System.Net.Http; | ||
|
||
namespace KubeClient.Utilities | ||
{ | ||
/// <summary> | ||
/// Helper methods for working with <see cref="HttpRequest"/> and related types. | ||
/// </summary> | ||
public static class HttpRequestHelper | ||
{ | ||
/// <summary> | ||
/// Expand an <see cref="HttpRequest"/>'s request URI, populating its URI template if necessary. | ||
/// </summary> | ||
/// <param name="request"> | ||
/// The target <see cref="HttpRequest"/>. | ||
/// </param> | ||
/// <param name="baseUri"> | ||
/// The base URI to use (optional, unless <see cref="HttpRequestBase.Uri"/> is <c>null</c> or not an absolute URI). | ||
/// </param> | ||
/// <returns> | ||
/// The expanded request URI (always an absolute URI). | ||
/// </returns> | ||
public static Uri ExpandRequestUri(this HttpRequest request, Uri baseUri = null) | ||
{ | ||
using (HttpRequestMessage requestMessage = request.BuildRequestMessage(HttpMethod.Get, body: null, baseUri)) | ||
{ | ||
return requestMessage.RequestUri; | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Expand an <see cref="HttpRequest{TContext}"/>'s request URI, populating its URI template if necessary. | ||
/// </summary> | ||
/// <typeparam name="TContext"> | ||
/// The type of object used as a context when evaluating request template parameters. | ||
/// </typeparam> | ||
/// <param name="request"> | ||
/// The target <see cref="HttpRequest{TContext}"/>. | ||
/// </param> | ||
/// <param name="context"> | ||
/// The <typeparamref name="TContext"/> used as a context when evaluating request template parameters. | ||
/// </param> | ||
/// <param name="baseUri"> | ||
/// The base URI to use (optional, unless <see cref="HttpRequestBase.Uri"/> is <c>null</c> or not an absolute URI). | ||
/// </param> | ||
/// <returns> | ||
/// The expanded request URI (always an absolute URI). | ||
/// </returns> | ||
public static Uri ExpandRequestUri<TContext>(this HttpRequest<TContext> request, TContext context, Uri baseUri = null) | ||
{ | ||
using (HttpRequestMessage requestMessage = request.BuildRequestMessage(HttpMethod.Get, context, body: null, baseUri)) | ||
{ | ||
return requestMessage.RequestUri; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters