aboutsummaryrefslogtreecommitdiff
path: root/lib/Net.Rest.Client/src/Construction
diff options
context:
space:
mode:
authorLibravatar vnugent <public@vaughnnugent.com>2023-08-05 00:52:48 -0400
committerLibravatar vnugent <public@vaughnnugent.com>2023-08-05 00:52:48 -0400
commit46c6450fdc9b62aa04bae545b03d93a2e8c8895a (patch)
treec5648e1ce68acd28cb29807ba65d90af3ba1caef /lib/Net.Rest.Client/src/Construction
parenta3ded6043a926735142f3bb48093e83135044c06 (diff)
Response compression buffer patch
Diffstat (limited to 'lib/Net.Rest.Client/src/Construction')
-rw-r--r--lib/Net.Rest.Client/src/Construction/Extensions.cs87
1 files changed, 87 insertions, 0 deletions
diff --git a/lib/Net.Rest.Client/src/Construction/Extensions.cs b/lib/Net.Rest.Client/src/Construction/Extensions.cs
index 52a1301..bbc8b1d 100644
--- a/lib/Net.Rest.Client/src/Construction/Extensions.cs
+++ b/lib/Net.Rest.Client/src/Construction/Extensions.cs
@@ -153,6 +153,21 @@ namespace VNLib.Net.Rest.Client.Construction
}
/// <summary>
+ /// Sets a callback that will create a query string argument value
+ /// </summary>
+ /// <typeparam name="TModel">The request entity type</typeparam>
+ /// <param name="builder"></param>
+ /// <param name="value">The constant query value</param>
+ /// <param name="parameter">The name of the query paramter to set</param>
+ /// <returns>The chainable <see cref="IRestRequestBuilder{TModel}"/></returns>
+ public static IRestRequestBuilder<TModel> WithQuery<TModel>(this IRestRequestBuilder<TModel> builder, string parameter, string value)
+ {
+ //Get a query item string value from the callback and sets the query paremter
+ builder.WithModifier((m, r) => r.AddQueryParameter(parameter, value));
+ return builder;
+ }
+
+ /// <summary>
/// Specifies a model that will handle its own request body builder
/// </summary>
/// <typeparam name="TModel"></typeparam>
@@ -182,6 +197,18 @@ namespace VNLib.Net.Rest.Client.Construction
}
/// <summary>
+ /// Allows building of a single endpoint from an <see cref="IRestEndpointDefinition"/> and stores it in the
+ /// adapter store.
+ /// </summary>
+ /// <param name="site"></param>
+ /// <returns>A chainable <see cref="IRestEndpointBuilder"/> to build the endpoint</returns>
+ public static IRestEndpointBuilder DefineSingleEndpoint(this IRestSiteEndpointStore site)
+ {
+ EndpointAdapterBuilder builder = new(site);
+ return builder;
+ }
+
+ /// <summary>
/// Sets the uri for all new request messages
/// </summary>
/// <typeparam name="TModel">The request entity type</typeparam>
@@ -195,6 +222,35 @@ namespace VNLib.Net.Rest.Client.Construction
return builder;
}
+
+ /// <summary>
+ /// Sets the uri for all new request messages
+ /// </summary>
+ /// <typeparam name="TModel">The request entity type</typeparam>
+ /// <param name="builder"></param>
+ /// <param name="uri">Specifies the uri for the request builder</param>
+ /// <returns>The chainable <see cref="IRestRequestBuilder{TModel}"/></returns>
+ public static IRestRequestBuilder<TModel> WithUrl<TModel>(this IRestRequestBuilder<TModel> builder, Uri uri)
+ {
+ //Use the supplied method to convert the uri to a string
+ builder.WithUrl((m) => uri.ToString());
+ return builder;
+ }
+
+ /// <summary>
+ /// Sets the uri for all new request messages
+ /// </summary>
+ /// <typeparam name="TModel">The request entity type</typeparam>
+ /// <param name="builder"></param>
+ /// <param name="url">Specifies the uri for the request builder</param>
+ /// <returns>The chainable <see cref="IRestRequestBuilder{TModel}"/></returns>
+ public static IRestRequestBuilder<TModel> WithUrl<TModel>(this IRestRequestBuilder<TModel> builder, string url)
+ {
+ //Use the supplied method to convert the uri to a string
+ builder.WithUrl((m) => url);
+ return builder;
+ }
+
/// <summary>
/// Specifies a connection header to set for every request
/// </summary>
@@ -226,6 +282,37 @@ namespace VNLib.Net.Rest.Client.Construction
}
/// <summary>
+ /// Sets a callback that will create a parameter string argument value
+ /// </summary>
+ /// <typeparam name="TModel">The request entity type</typeparam>
+ /// <param name="builder"></param>
+ /// <param name="callback">The callback method that gets the query value</param>
+ /// <param name="parameter">The body paramter value to set</param>
+ /// <returns>The chainable <see cref="IRestRequestBuilder{TModel}"/></returns>
+ public static IRestRequestBuilder<TModel> WithParameter<TModel>(this IRestRequestBuilder<TModel> builder, string parameter, Func<TModel, string> callback)
+ {
+ //Get a query item string value from the callback and sets the query paremter
+ builder.WithModifier((m, r) => r.AddParameter(parameter, callback(m), ParameterType.GetOrPost));
+ return builder;
+ }
+
+ /// <summary>
+ /// Sets a constant parameter string argument value
+ /// </summary>
+ /// <typeparam name="TModel">The request entity type</typeparam>
+ /// <param name="builder"></param>
+ /// <param name="value">The constant value</param>
+ /// <param name="parameter">The query paramter value to set</param>
+ /// <returns>The chainable <see cref="IRestRequestBuilder{TModel}"/></returns>
+ public static IRestRequestBuilder<TModel> WithParameter<TModel>(this IRestRequestBuilder<TModel> builder, string parameter, string value)
+ {
+ //Get a query item string value from the callback and sets the query paremter
+ builder.WithModifier((m, r) => r.AddParameter(parameter, value, ParameterType.GetOrPost));
+ return builder;
+ }
+
+
+ /// <summary>
/// Converts a task that resolves a <see cref="RestResponse"/> to a task that deserializes
/// the response data as json.
/// </summary>