Class HttpLayoutRequestHandlerBuilderExtensions

Version: 21.x

Extension methods to support configuration of layout service request handler services.

Inheritance
System.Object
HttpLayoutRequestHandlerBuilderExtensions
Namespace: Sitecore.LayoutService.Client.Extensions
Assembly: Sitecore.LayoutService.Client.dll
Syntax
RequestResponse
public static class HttpLayoutRequestHandlerBuilderExtensions : Object

Methods

AddHttpHandler(ISitecoreLayoutClientBuilder, String, Action<IServiceProvider, HttpClient>)

Registers a HTTP request handler for the Sitecore layout service client.

Declaration
RequestResponse
public static ILayoutRequestHandlerBuilder<HttpLayoutRequestHandler> AddHttpHandler(this ISitecoreLayoutClientBuilder builder, string handlerName, Action<IServiceProvider, HttpClient> configure)
Parameters
TypeNameDescription
ISitecoreLayoutClientBuilderbuilder

The ISitecoreLayoutClientBuilder to configure.

System.StringhandlerName

The name of the request handler being registered.

System.Action<System.IServiceProvider, System.Net.Http.HttpClient>configure

An action to configure the System.Net.Http.HttpClient.

Returns
TypeDescription
ILayoutRequestHandlerBuilder<HttpLayoutRequestHandler>

The ILayoutRequestHandlerBuilder<THandler> so that additional calls can be chained.

AddHttpHandler(ISitecoreLayoutClientBuilder, String, Action<HttpClient>)

Registers a HTTP request handler for the Sitecore layout service client.

Declaration
RequestResponse
public static ILayoutRequestHandlerBuilder<HttpLayoutRequestHandler> AddHttpHandler(this ISitecoreLayoutClientBuilder builder, string handlerName, Action<HttpClient> configure)
Parameters
TypeNameDescription
ISitecoreLayoutClientBuilderbuilder

The ISitecoreLayoutClientBuilder to configure.

System.StringhandlerName

The name of the request handler being registered.

System.Action<System.Net.Http.HttpClient>configure

An action to configure the System.Net.Http.HttpClient.

Returns
TypeDescription
ILayoutRequestHandlerBuilder<HttpLayoutRequestHandler>

The ILayoutRequestHandlerBuilder<THandler> so that additional calls can be chained.

AddHttpHandler(ISitecoreLayoutClientBuilder, String, Func<IServiceProvider, HttpClient>)

Registers a HTTP request handler for the Sitecore layout service client.

Declaration
RequestResponse
public static ILayoutRequestHandlerBuilder<HttpLayoutRequestHandler> AddHttpHandler(this ISitecoreLayoutClientBuilder builder, string handlerName, Func<IServiceProvider, HttpClient> resolveClient)
Parameters
TypeNameDescription
ISitecoreLayoutClientBuilderbuilder

The ISitecoreLayoutClientBuilder to configure.

System.StringhandlerName

The name of the request handler being registered.

System.Func<System.IServiceProvider, System.Net.Http.HttpClient>resolveClient

A function to resolve the System.Net.Http.HttpClient to be used. Be aware, that the the underlying System.Net.Http.HttpMessageHandler associated to the HttpClient will be reused across multiple sessions. To prevent data, leaking among sessions, make sure Cookies are not cached. See for reference https://docs.microsoft.com/en-us/aspnet/core/fundamentals/http-requests?view=aspnetcore-3.1#cookies .

Returns
TypeDescription
ILayoutRequestHandlerBuilder<HttpLayoutRequestHandler>

The ILayoutRequestHandlerBuilder<THandler> so that additional calls can be chained.

AddHttpHandler(ISitecoreLayoutClientBuilder, String, Func<IServiceProvider, HttpClient>, String[])

Registers a HTTP request handler for the Sitecore layout service client.

Declaration
RequestResponse
public static ILayoutRequestHandlerBuilder<HttpLayoutRequestHandler> AddHttpHandler(this ISitecoreLayoutClientBuilder builder, string handlerName, Func<IServiceProvider, HttpClient> resolveClient, string[] nonValidatedHeaders)
Parameters
TypeNameDescription
ISitecoreLayoutClientBuilderbuilder

The ISitecoreLayoutClientBuilder to configure.

System.StringhandlerName

The name of the request handler being registered.

System.Func<System.IServiceProvider, System.Net.Http.HttpClient>resolveClient

A function to resolve the System.Net.Http.HttpClient to be used. Be aware, that the the underlying System.Net.Http.HttpMessageHandler associated to the HttpClient will be reused across multiple sessions. To prevent data, leaking among sessions, make sure Cookies are not cached. See for reference https://docs.microsoft.com/en-us/aspnet/core/fundamentals/http-requests?view=aspnetcore-3.1#cookies .

System.String[]nonValidatedHeaders

The list of headers which should not be validated.

Returns
TypeDescription
ILayoutRequestHandlerBuilder<HttpLayoutRequestHandler>

The ILayoutRequestHandlerBuilder<THandler> so that additional calls can be chained.

AddHttpHandler(ISitecoreLayoutClientBuilder, String, String)

Registers a HTTP request handler for the Sitecore layout service client.

Declaration
RequestResponse
public static ILayoutRequestHandlerBuilder<HttpLayoutRequestHandler> AddHttpHandler(this ISitecoreLayoutClientBuilder builder, string handlerName, string uri)
Parameters
TypeNameDescription
ISitecoreLayoutClientBuilderbuilder

The ISitecoreLayoutClientBuilder to configure.

System.StringhandlerName

The name of the request handler being registered.

System.Stringuri

The System.Uri used for the System.Net.Http.HttpClient.BaseAddress.

Returns
TypeDescription
ILayoutRequestHandlerBuilder<HttpLayoutRequestHandler>

The ILayoutRequestHandlerBuilder<THandler> so that additional calls can be chained.

AddHttpHandler(ISitecoreLayoutClientBuilder, String, Uri)

Registers a HTTP request handler for the Sitecore layout service client.

Declaration
RequestResponse
public static ILayoutRequestHandlerBuilder<HttpLayoutRequestHandler> AddHttpHandler(this ISitecoreLayoutClientBuilder builder, string handlerName, Uri uri)
Parameters
TypeNameDescription
ISitecoreLayoutClientBuilderbuilder

The ISitecoreLayoutClientBuilder to configure.

System.StringhandlerName

The name of the request handler being registered.

System.Uriuri

The System.Uri used for the System.Net.Http.HttpClient.BaseAddress.

Returns
TypeDescription
ILayoutRequestHandlerBuilder<HttpLayoutRequestHandler>

The ILayoutRequestHandlerBuilder<THandler> so that additional calls can be chained.

ConfigureRequest(ILayoutRequestHandlerBuilder<HttpLayoutRequestHandler>, String[])

Adds default configuration for the HTTP request message.

Declaration
RequestResponse
public static ILayoutRequestHandlerBuilder<HttpLayoutRequestHandler> ConfigureRequest(this ILayoutRequestHandlerBuilder<HttpLayoutRequestHandler> httpHandlerBuilder, string[] nonValidatedHeaders)
Parameters
TypeNameDescription
ILayoutRequestHandlerBuilder<HttpLayoutRequestHandler>httpHandlerBuilder

The ILayoutRequestHandlerBuilder<THandler> to configure.

System.String[]nonValidatedHeaders

The list of headers which should not be validated.

Returns
TypeDescription
ILayoutRequestHandlerBuilder<HttpLayoutRequestHandler>

The ILayoutRequestHandlerBuilder<THandler> so that additional calls can be chained.

MapFromRequest(ILayoutRequestHandlerBuilder<HttpLayoutRequestHandler>, Action<SitecoreLayoutRequest, HttpRequestMessage>)

Registers a System.Net.Http.HttpRequestMessage configuration action as named HttpLayoutRequestHandlerOptions for the given handler.

Declaration
RequestResponse
public static ILayoutRequestHandlerBuilder<HttpLayoutRequestHandler> MapFromRequest(this ILayoutRequestHandlerBuilder<HttpLayoutRequestHandler> builder, Action<SitecoreLayoutRequest, HttpRequestMessage> configureHttpRequestMessage)
Parameters
TypeNameDescription
ILayoutRequestHandlerBuilder<HttpLayoutRequestHandler>builder

The ILayoutRequestHandlerBuilder<THandler> to configure.

System.Action<SitecoreLayoutRequest, System.Net.Http.HttpRequestMessage>configureHttpRequestMessage

The System.Net.Http.HttpRequestMessage configuration based on SitecoreLayoutRequest.

Returns

Do you have some feedback for us?

If you have suggestions for improving this article,