Class SitecoreLayoutClientBuilderExtensions
- Namespace
- Sitecore.AspNetCore.SDK.LayoutService.Client.Extensions
- Assembly
- Sitecore.AspNetCore.SDK.LayoutService.Client.dll
Extension methods to support configuration of layout service services.
public static class SitecoreLayoutClientBuilderExtensions
- Inheritance
-
SitecoreLayoutClientBuilderExtensions
- Inherited Members
Methods
AddGraphQlHandler(ISitecoreLayoutClientBuilder, string, string, string)
Registers a graphQl handler to handle requests, it uses already configured GraphQL client.
public static ILayoutRequestHandlerBuilder<GraphQlLayoutServiceHandler> AddGraphQlHandler(this ISitecoreLayoutClientBuilder builder, string name, string siteName, string defaultLanguage = "en")
Parameters
builder
ISitecoreLayoutClientBuilderThe ISitecoreLayoutClientBuilder being configured.
name
stringThe name used to identify the handler.
siteName
stringThe siteName used to identify the handler.
defaultLanguage
stringDefault language for GraphQl requests.
Returns
- ILayoutRequestHandlerBuilder<GraphQlLayoutServiceHandler>
The ILayoutRequestHandlerBuilder<THandler> so that additional calls can be chained.
AddGraphQlHandler(ISitecoreLayoutClientBuilder, string, string, string, Uri, string)
Registers a graphQl handler to handle requests.
public static ILayoutRequestHandlerBuilder<GraphQlLayoutServiceHandler> AddGraphQlHandler(this ISitecoreLayoutClientBuilder builder, string name, string siteName, string apiKey, Uri uri, string defaultLanguage = "en")
Parameters
builder
ISitecoreLayoutClientBuilderThe ISitecoreLayoutClientBuilder being configured.
name
stringThe name used to identify the handler.
siteName
stringThe siteName used to identify the handler.
apiKey
stringThe apiKey to access graphQl endpoint.
uri
UriGraphQl endpoint uri.
defaultLanguage
stringDefault language for GraphQl requests.
Returns
- ILayoutRequestHandlerBuilder<GraphQlLayoutServiceHandler>
The ILayoutRequestHandlerBuilder<THandler> so that additional calls can be chained.
AddGraphQlWithContextHandler(ISitecoreLayoutClientBuilder, string, string, Uri?, string?, string)
Registers a graphQl handler to handle requests.
public static ILayoutRequestHandlerBuilder<GraphQlLayoutServiceHandler> AddGraphQlWithContextHandler(this ISitecoreLayoutClientBuilder builder, string name, string contextId, Uri? uri = null, string? siteName = null, string defaultLanguage = "en")
Parameters
builder
ISitecoreLayoutClientBuilderThe ISitecoreLayoutClientBuilder being configured.
name
stringThe name used to identify the handler.
contextId
stringThe context identifier to access graphQl endpoint.
uri
UriGraphQl endpoint uri.
siteName
stringThe siteName used to identify the handler.
defaultLanguage
stringDefault language for GraphQl requests.
Returns
- ILayoutRequestHandlerBuilder<GraphQlLayoutServiceHandler>
The ILayoutRequestHandlerBuilder<THandler> so that additional calls can be chained.
AddHandler<THandler>(ISitecoreLayoutClientBuilder, string, Func<IServiceProvider, THandler>?)
Registers a handler of type THandler
to handle requests.
public static ILayoutRequestHandlerBuilder<THandler> AddHandler<THandler>(this ISitecoreLayoutClientBuilder builder, string name, Func<IServiceProvider, THandler>? factory = null) where THandler : ILayoutRequestHandler
Parameters
builder
ISitecoreLayoutClientBuilderThe ISitecoreLayoutClientBuilder being configured.
name
stringThe name used to identify the handler.
factory
Func<IServiceProvider, THandler>Optional factory to control the instantiation of the client.
Returns
- ILayoutRequestHandlerBuilder<THandler>
The ILayoutRequestHandlerBuilder<THandler> so that additional calls can be chained.
Type Parameters
THandler
The type of service to be registered for this
name
.
AddHttpHandler(ISitecoreLayoutClientBuilder, string, Action<IServiceProvider, HttpClient>)
Registers an HTTP request handler for the Sitecore layout service client.
public static ILayoutRequestHandlerBuilder<HttpLayoutRequestHandler> AddHttpHandler(this ISitecoreLayoutClientBuilder builder, string handlerName, Action<IServiceProvider, HttpClient> configure)
Parameters
builder
ISitecoreLayoutClientBuilderThe ISitecoreLayoutClientBuilder to configure.
handlerName
stringThe name of the request handler being registered.
configure
Action<IServiceProvider, HttpClient>An action to configure the HttpClient.
Returns
- ILayoutRequestHandlerBuilder<HttpLayoutRequestHandler>
The ILayoutRequestHandlerBuilder<THandler> so that additional calls can be chained.
AddHttpHandler(ISitecoreLayoutClientBuilder, string, Action<HttpClient>)
Registers an HTTP request handler for the Sitecore layout service client.
public static ILayoutRequestHandlerBuilder<HttpLayoutRequestHandler> AddHttpHandler(this ISitecoreLayoutClientBuilder builder, string handlerName, Action<HttpClient> configure)
Parameters
builder
ISitecoreLayoutClientBuilderThe ISitecoreLayoutClientBuilder to configure.
handlerName
stringThe name of the request handler being registered.
configure
Action<HttpClient>An action to configure the HttpClient.
Returns
- ILayoutRequestHandlerBuilder<HttpLayoutRequestHandler>
The ILayoutRequestHandlerBuilder<THandler> so that additional calls can be chained.
AddHttpHandler(ISitecoreLayoutClientBuilder, string, Func<IServiceProvider, HttpClient>)
Registers an HTTP request handler for the Sitecore layout service client.
public static ILayoutRequestHandlerBuilder<HttpLayoutRequestHandler> AddHttpHandler(this ISitecoreLayoutClientBuilder builder, string handlerName, Func<IServiceProvider, HttpClient> resolveClient)
Parameters
builder
ISitecoreLayoutClientBuilderThe ISitecoreLayoutClientBuilder to configure.
handlerName
stringThe name of the request handler being registered.
resolveClient
Func<IServiceProvider, HttpClient>A function to resolve the HttpClient to be used. Be aware, that the underlying 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
- ILayoutRequestHandlerBuilder<HttpLayoutRequestHandler>
The ILayoutRequestHandlerBuilder<THandler> so that additional calls can be chained.
AddHttpHandler(ISitecoreLayoutClientBuilder, string, Func<IServiceProvider, HttpClient>, string[])
Registers an HTTP request handler for the Sitecore layout service client.
public static ILayoutRequestHandlerBuilder<HttpLayoutRequestHandler> AddHttpHandler(this ISitecoreLayoutClientBuilder builder, string handlerName, Func<IServiceProvider, HttpClient> resolveClient, string[] nonValidatedHeaders)
Parameters
builder
ISitecoreLayoutClientBuilderThe ISitecoreLayoutClientBuilder to configure.
handlerName
stringThe name of the request handler being registered.
resolveClient
Func<IServiceProvider, HttpClient>A function to resolve the HttpClient to be used. Be aware, that the underlying 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 .
nonValidatedHeaders
string[]The list of headers which should not be validated.
Returns
- ILayoutRequestHandlerBuilder<HttpLayoutRequestHandler>
The ILayoutRequestHandlerBuilder<THandler> so that additional calls can be chained.
AddHttpHandler(ISitecoreLayoutClientBuilder, string, string)
Registers an HTTP request handler for the Sitecore layout service client.
public static ILayoutRequestHandlerBuilder<HttpLayoutRequestHandler> AddHttpHandler(this ISitecoreLayoutClientBuilder builder, string handlerName, string uri)
Parameters
builder
ISitecoreLayoutClientBuilderThe ISitecoreLayoutClientBuilder to configure.
handlerName
stringThe name of the request handler being registered.
uri
stringThe Uri used for the BaseAddress.
Returns
- ILayoutRequestHandlerBuilder<HttpLayoutRequestHandler>
The ILayoutRequestHandlerBuilder<THandler> so that additional calls can be chained.
AddHttpHandler(ISitecoreLayoutClientBuilder, string, Uri)
Registers an HTTP request handler for the Sitecore layout service client.
public static ILayoutRequestHandlerBuilder<HttpLayoutRequestHandler> AddHttpHandler(this ISitecoreLayoutClientBuilder builder, string handlerName, Uri uri)
Parameters
builder
ISitecoreLayoutClientBuilderThe ISitecoreLayoutClientBuilder to configure.
handlerName
stringThe name of the request handler being registered.
uri
UriThe Uri used for the BaseAddress.
Returns
- ILayoutRequestHandlerBuilder<HttpLayoutRequestHandler>
The ILayoutRequestHandlerBuilder<THandler> so that additional calls can be chained.
WithDefaultRequestOptions(ISitecoreLayoutClientBuilder, Action<SitecoreLayoutRequest>)
Registers the default layout service request options for all handlers.
public static ISitecoreLayoutClientBuilder WithDefaultRequestOptions(this ISitecoreLayoutClientBuilder builder, Action<SitecoreLayoutRequest> configureRequest)
Parameters
builder
ISitecoreLayoutClientBuilderThe ISitecoreLayoutClientBuilder being configured.
configureRequest
Action<SitecoreLayoutRequest>The SitecoreLayoutRequest request options configuration.
Returns
- ISitecoreLayoutClientBuilder
The configured ISitecoreLayoutClientBuilder.