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
public static class HttpLayoutRequestHandlerBuilderExtensions : Object

Methods

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

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

Declaration
public static ILayoutRequestHandlerBuilder<HttpLayoutRequestHandler> AddHttpHandler(this ISitecoreLayoutClientBuilder builder, string handlerName, Action<IServiceProvider, HttpClient> configure)
Parameters
TypeNameDescription
ISitecoreLayoutClientBuilderbuilderThe ISitecoreLayoutClientBuilder to configure.
System.StringhandlerNameThe name of the request handler being registered.
System.Action

<

System.IServiceProvider

,

System.Net.Http.HttpClient

>
configureAn action to configure the System.Net.Http.HttpClient.
Returns
TypeDescription
ILayoutRequestHandlerBuilder

<

HttpLayoutRequestHandler

>
The ILayoutRequestHandlerBuilder so that additional calls can be chained.

AddHttpHandler(ISitecoreLayoutClientBuilder, String, Action)

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

Declaration
public static ILayoutRequestHandlerBuilder<HttpLayoutRequestHandler> AddHttpHandler(this ISitecoreLayoutClientBuilder builder, string handlerName, Action<HttpClient> configure)
Parameters
TypeNameDescription
ISitecoreLayoutClientBuilderbuilderThe ISitecoreLayoutClientBuilder to configure.
System.StringhandlerNameThe name of the request handler being registered.
System.Action

<

System.Net.Http.HttpClient

>
configureAn action to configure the System.Net.Http.HttpClient.
Returns
TypeDescription
ILayoutRequestHandlerBuilder

<

HttpLayoutRequestHandler

>
The ILayoutRequestHandlerBuilder 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
public static ILayoutRequestHandlerBuilder<HttpLayoutRequestHandler> AddHttpHandler(this ISitecoreLayoutClientBuilder builder, string handlerName, Func<IServiceProvider, HttpClient> resolveClient)
Parameters
TypeNameDescription
ISitecoreLayoutClientBuilderbuilderThe ISitecoreLayoutClientBuilder to configure.
System.StringhandlerNameThe name of the request handler being registered.
System.Func

<

System.IServiceProvider

,

System.Net.Http.HttpClient

>
resolveClientA 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 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
public static ILayoutRequestHandlerBuilder<HttpLayoutRequestHandler> AddHttpHandler(this ISitecoreLayoutClientBuilder builder, string handlerName, Func<IServiceProvider, HttpClient> resolveClient, string[] nonValidatedHeaders)
Parameters
TypeNameDescription
ISitecoreLayoutClientBuilderbuilderThe ISitecoreLayoutClientBuilder to configure.
System.StringhandlerNameThe name of the request handler being registered.
System.Func

<

System.IServiceProvider

,

System.Net.Http.HttpClient

>
resolveClientA 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

[]
nonValidatedHeadersThe list of headers which should not be validated.
Returns
TypeDescription
ILayoutRequestHandlerBuilder

<

HttpLayoutRequestHandler

>
The ILayoutRequestHandlerBuilder so that additional calls can be chained.

AddHttpHandler(ISitecoreLayoutClientBuilder, String, String)

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

Declaration
public static ILayoutRequestHandlerBuilder<HttpLayoutRequestHandler> AddHttpHandler(this ISitecoreLayoutClientBuilder builder, string handlerName, string uri)
Parameters
TypeNameDescription
ISitecoreLayoutClientBuilderbuilderThe ISitecoreLayoutClientBuilder to configure.
System.StringhandlerNameThe name of the request handler being registered.
System.StringuriThe System.Uri used for the System.Net.Http.HttpClient.BaseAddress.
Returns
TypeDescription
ILayoutRequestHandlerBuilder

<

HttpLayoutRequestHandler

>
The ILayoutRequestHandlerBuilder so that additional calls can be chained.

AddHttpHandler(ISitecoreLayoutClientBuilder, String, Uri)

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

Declaration
public static ILayoutRequestHandlerBuilder<HttpLayoutRequestHandler> AddHttpHandler(this ISitecoreLayoutClientBuilder builder, string handlerName, Uri uri)
Parameters
TypeNameDescription
ISitecoreLayoutClientBuilderbuilderThe ISitecoreLayoutClientBuilder to configure.
System.StringhandlerNameThe name of the request handler being registered.
System.UriuriThe System.Uri used for the System.Net.Http.HttpClient.BaseAddress.
Returns
TypeDescription
ILayoutRequestHandlerBuilder

<

HttpLayoutRequestHandler

>
The ILayoutRequestHandlerBuilder so that additional calls can be chained.

ConfigureRequest(ILayoutRequestHandlerBuilder, String[])

Adds default configuration for the HTTP request message.

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

<

HttpLayoutRequestHandler

>
httpHandlerBuilderThe ILayoutRequestHandlerBuilder to configure.
System.String

[]
nonValidatedHeadersThe list of headers which should not be validated.
Returns
TypeDescription
ILayoutRequestHandlerBuilder

<

HttpLayoutRequestHandler

>
The ILayoutRequestHandlerBuilder so that additional calls can be chained.

MapFromRequest(ILayoutRequestHandlerBuilder, Action<SitecoreLayoutRequest, HttpRequestMessage>)

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

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

<

HttpLayoutRequestHandler

>
builderThe ILayoutRequestHandlerBuilder to configure.
System.Action

<

SitecoreLayoutRequest

,

System.Net.Http.HttpRequestMessage

>
configureHttpRequestMessageThe System.Net.Http.HttpRequestMessage configuration based on SitecoreLayoutRequest.
Returns
TypeDescription
ILayoutRequestHandlerBuilder

<

HttpLayoutRequestHandler

>
The configured ILayoutRequestHandlerBuilder.
If you have suggestions for improving this article, let us know!