Class ApiContext<TModel, TUser>
Context for an API request
Namespace: Seltzr.Context
Assembly: Seltzr.dll
Syntax
public class ApiContext<TModel, TUser> : IDisposable, IApiContext<TModel, 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
Constructors
Initializes a new instance of the ApiContext<TModel, TUser> class.
public ApiContext(HttpContext httpContext, Response<TModel> response)
Parameters
httpContext
HttpContext
The current HttpContext for this request
response
Response<TModel>
The response for this API call
Properties
Gets the current HttpContext for this request
public virtual HttpContext HttpContext { get; }
Property Value
HttpContextGets the current HTTP response context. Shortcut to Response
public virtual 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.
public virtual ParseResult<TModel>[] Parsed { get; }
Property Value
ParseResult<TModel>[]Gets the current request context. Shortcut to Request
public virtual HttpRequest Request { get; }
Property Value
HttpRequestGets the response for this API call. If this is null, the model itself will be serialized instead.
public virtual Response<TModel> Response { get; }
Property Value
Response<TModel>Gets a service provider for this API context
public virtual 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.
public virtual TUser User { get; }
Property Value
TUserMethods
Disposes the ApiContext<TModel, TUser>
public void Dispose()