Interface IApiContext<TModel, TUser>
Context for an API request.
Namespace: Seltzr.Context
Assembly: Seltzr.dll
Syntax
public interface IApiContext<TModel, out TUser>
where TModel : class where TUser : class
Type Parameters
TModel
The type of model being managed by the AP
TUser
The type of authenticated user context
Remarks
The API Context lives for the duration of a single route execution and contains a number of useful properties which are passed to many steps of the request flow. The API Context provides access to the parsed request body, the response wrapper, and a scoped service provider to Auth Providers, Conditions, Filters, Model Providers, Operations, Parsers, and Result Writers.
Properties
Gets the current HttpContext for this request
HttpContext HttpContext { get; }
Property Value
HttpContextGets the current HTTP response context. Shortcut to Response
HttpResponse HttpResponse { get; }
Property Value
HttpResponseGets the models that have been parsed by the body parser. This may be null if the body has not been parsed yet or there are no body parsers registered for this route.
ParseResult<TModel>[] Parsed { get; }
Property Value
ParseResult<TModel>[]Gets the current request context. Shortcut to Request
HttpRequest Request { get; }
Property Value
HttpRequestGets the response for this API call. If this is null, the model itself will be serialized instead.
Response<TModel> Response { get; }
Property Value
Response<TModel>Gets a service provider for this API context
IServiceProvider Services { get; }
Property Value
IServiceProviderGets the authenticated user context for this route. This may be null if authorization has not yet occurred or there are no auth providers registered for this route.
TUser User { get; }