/// <summary> /// Initializes a new instance of the <see cref="DefaultApiVersionRoutePolicy"/> class. /// </summary> /// <param name="actionInvokerFactory">The underlying <see cref="IActionInvokerFactory">action invoker factory</see>.</param> /// <param name="errorResponseProvider">The <see cref="IErrorResponseProvider">provider</see> used to create error responses.</param> /// <param name="reportApiVersions">The <see cref="IReportApiVersions">object</see> used to report API versions.</param> /// <param name="loggerFactory">The <see cref="ILoggerFactory"/>.</param> public DefaultApiVersionRoutePolicy( IActionInvokerFactory actionInvokerFactory, IErrorResponseProvider errorResponseProvider, IReportApiVersions reportApiVersions, ILoggerFactory loggerFactory) : this(actionInvokerFactory, errorResponseProvider, reportApiVersions, loggerFactory, null) { }
internal RequestHandlerContext( IErrorResponseProvider errorResponseProvider, IReportApiVersions?reportApiVersions, Lazy <ApiVersionModel>?apiVersions) { ErrorResponses = errorResponseProvider; reporter = reportApiVersions; this.apiVersions = apiVersions; }
protected RequestHandler(IErrorResponseProvider errorResponseProvider, string code, string message) { Contract.Requires(errorResponseProvider != null); Contract.Requires(!string.IsNullOrEmpty(message)); ErrorResponses = errorResponseProvider; Message = message; Code = code; }
internal RequestHandlerContext( IErrorResponseProvider errorResponseProvider, IReportApiVersions reportApiVersions) : this( errorResponseProvider, reportApiVersions, new Lazy <ApiVersionModel>(() => ApiVersionModel.Empty)) { }
/// <summary> /// Initializes a new instance of the <see cref="DefaultApiVersionRoutePolicy"/> class. /// </summary> /// <param name="errorResponseProvider">The <see cref="IErrorResponseProvider">provider</see> used to create error responses.</param> /// <param name="reportApiVersions">The <see cref="IReportApiVersions">object</see> used to report API versions.</param> /// <param name="loggerFactory">The <see cref="ILoggerFactory"/>.</param> /// <param name="options">The <see cref="ApiVersioningOptions">options</see> associated with the route policy.</param> public DefaultApiVersionRoutePolicy( IErrorResponseProvider errorResponseProvider, IReportApiVersions reportApiVersions, ILoggerFactory loggerFactory, IOptions <ApiVersioningOptions> options) { ErrorResponseProvider = errorResponseProvider; ApiVersionReporter = reportApiVersions; Logger = loggerFactory.CreateLogger(GetType()); this.options = options; }
internal RequestHandlerContext( IErrorResponseProvider errorResponseProvider, IReportApiVersions reportApiVersions, Lazy <ApiVersionModel> apiVersions) { Contract.Requires(errorResponseProvider != null); ErrorResponses = errorResponseProvider; reporter = reportApiVersions; this.apiVersions = apiVersions; }
internal RequestHandlerContext( IErrorResponseProvider errorResponseProvider, #pragma warning disable CS8632 // The annotation for nullable reference types should only be used in code within a '#nullable' annotations context. IReportApiVersions?reportApiVersions, #pragma warning restore CS8632 // The annotation for nullable reference types should only be used in code within a '#nullable' annotations context. #pragma warning disable CS8632 // The annotation for nullable reference types should only be used in code within a '#nullable' annotations context. Lazy <ApiVersionModel>?apiVersions) #pragma warning restore CS8632 // The annotation for nullable reference types should only be used in code within a '#nullable' annotations context. { ErrorResponses = errorResponseProvider; reporter = reportApiVersions; this.apiVersions = apiVersions; }
/// <summary> /// Initializes a new instance of the <see cref="DefaultApiVersionRoutePolicy"/> class. /// </summary> /// <param name="actionInvokerFactory">The underlying <see cref="IActionInvokerFactory">action invoker factory</see>.</param> /// <param name="errorResponseProvider">The <see cref="IErrorResponseProvider">provider</see> used to create error responses.</param> /// <param name="loggerFactory">The <see cref="ILoggerFactory"/>.</param> /// <param name="actionContextAccessor">The associated <see cref="IActionContextAccessor">action context accessor</see>.</param> public DefaultApiVersionRoutePolicy( IActionInvokerFactory actionInvokerFactory, IErrorResponseProvider errorResponseProvider, ILoggerFactory loggerFactory, IActionContextAccessor actionContextAccessor) { Arg.NotNull(actionInvokerFactory, nameof(actionInvokerFactory)); Arg.NotNull(errorResponseProvider, nameof(errorResponseProvider)); Arg.NotNull(loggerFactory, nameof(loggerFactory)); ErrorResponseProvider = errorResponseProvider; ActionInvokerFactory = actionInvokerFactory; Logger = loggerFactory.CreateLogger(GetType()); ActionContextAccessor = actionContextAccessor; }
/// <summary> /// Initializes a new instance of the <see cref="DefaultApiVersionRoutePolicy"/> class. /// </summary> /// <param name="errorResponseProvider">The <see cref="IErrorResponseProvider">provider</see> used to create error responses.</param> /// <param name="reportApiVersions">The <see cref="IReportApiVersions">object</see> used to report API versions.</param> /// <param name="loggerFactory">The <see cref="ILoggerFactory"/>.</param> /// <param name="options">The <see cref="ApiVersioningOptions">options</see> associated with the route policy.</param> public DefaultApiVersionRoutePolicy( IErrorResponseProvider errorResponseProvider, IReportApiVersions reportApiVersions, ILoggerFactory loggerFactory, IOptions <ApiVersioningOptions> options) { Arg.NotNull(errorResponseProvider, nameof(errorResponseProvider)); Arg.NotNull(reportApiVersions, nameof(reportApiVersions)); Arg.NotNull(loggerFactory, nameof(loggerFactory)); Arg.NotNull(options, nameof(options)); ErrorResponseProvider = errorResponseProvider; ApiVersionReporter = reportApiVersions; Logger = loggerFactory.CreateLogger(GetType()); this.options = options; }
/// <summary> /// Initializes a new instance of the <see cref="DefaultApiVersionRoutePolicy"/> class. /// </summary> /// <param name="actionInvokerFactory">The underlying <see cref="IActionInvokerFactory">action invoker factory</see>.</param> /// <param name="errorResponseProvider">The <see cref="IErrorResponseProvider">provider</see> used to create error responses.</param> /// <param name="reportApiVersions">The <see cref="IReportApiVersions">object</see> used to report API versions.</param> /// <param name="loggerFactory">The <see cref="ILoggerFactory"/>.</param> /// <param name="actionContextAccessor">The associated <see cref="IActionContextAccessor">action context accessor</see>.</param> /// <param name="options">The <see cref="ApiVersioningOptions">options</see> associated with the route policy.</param> public DefaultApiVersionRoutePolicy( IActionInvokerFactory actionInvokerFactory, IErrorResponseProvider errorResponseProvider, IReportApiVersions reportApiVersions, ILoggerFactory loggerFactory, IActionContextAccessor actionContextAccessor, IOptions <ApiVersioningOptions> options = null) { Arg.NotNull(actionInvokerFactory, nameof(actionInvokerFactory)); Arg.NotNull(errorResponseProvider, nameof(errorResponseProvider)); Arg.NotNull(reportApiVersions, nameof(reportApiVersions)); Arg.NotNull(loggerFactory, nameof(loggerFactory)); ErrorResponseProvider = errorResponseProvider; ActionInvokerFactory = actionInvokerFactory; ApiVersionReporter = reportApiVersions; Logger = loggerFactory.CreateLogger(GetType()); ActionContextAccessor = actionContextAccessor; this.options = options ?? new OptionsWrapper <ApiVersioningOptions>(new ApiVersioningOptions()); }
internal RequestHandlerContext(IErrorResponseProvider errorResponseProvider) : this(errorResponseProvider, null, null) { }
internal BadRequestHandler(IErrorResponseProvider errorResponseProvider, string code, string message) : base(errorResponseProvider, code, message) { }
internal MethodNotAllowedHandler(IErrorResponseProvider errorResponseProvider, string code, string message, string[] allowedMethods) : base(errorResponseProvider, code, message) { Contract.Requires(allowedMethods != null); this.allowedMethods = allowedMethods; }
#pragma warning disable CS8632 // The annotation for nullable reference types should only be used in code within a '#nullable' annotations context. internal static IActionResult MethodNotAllowed(this IErrorResponseProvider responseProvider, HttpContext context, string code, string message, string?messageDetail = null) => #pragma warning restore CS8632 // The annotation for nullable reference types should only be used in code within a '#nullable' annotations context. responseProvider.CreateResponse(new ErrorResponseContext(context.Request, Status405MethodNotAllowed, code, message, messageDetail));
internal static IActionResult MethodNotAllowed(this IErrorResponseProvider responseProvider, HttpContext context, string code, string message, string?messageDetail = null) => responseProvider.CreateResponse(new ErrorResponseContext(context.Request, Status405MethodNotAllowed, code, message, messageDetail));
internal static HttpResponseMessage BadRequest(this IErrorResponseProvider responseProvider, HttpRequestMessage request, string code, string message, string messageDetail = null) => responseProvider.CreateResponse(new ErrorResponseContext(request, HttpStatusCode.BadRequest, code, message, messageDetail));
internal static IActionResult BadRequest(this IErrorResponseProvider responseProvider, HttpContext context, string code, string message, string messageDetail = null) => responseProvider.CreateResponse(new ErrorResponseContext(context.Request, Status400BadRequest, code, message, messageDetail));