public ActionConvention(IOptions <JsonRpcOptions> options, IEnumerable <IJsonRpcSerializer> serializers, IMethodMatcher methodMatcher, IJsonRpcRoutes jsonRpcRoutes, ILogger <ActionConvention> log) { this.serializers = serializers; this.methodMatcher = methodMatcher; this.jsonRpcRoutes = jsonRpcRoutes; this.log = log; defaultMethodOptions = options.Value.DefaultMethodOptions; }
public async Task Invoke(HttpContext context, IRequestHandler requestHandler, IJsonRpcRoutes jsonRpcRoutes) { log.LogTrace($"Started"); var contentType = context.Request.GetTypedHeaders().ContentType; if (!Utils.ProbablyIsJsonRpc(context.Request, contentType)) { log.LogTrace($"Request is not recognized as JSON Rpc"); await next(context); return; } if (!jsonRpcRoutes.IsJsonRpcRoute(context.Request.Path)) { log.LogTrace($"Request path is not registered as JSON Rpc"); await next(context); return; } // TODO properly handle RESPONSE encoding as TextOutputFormatter does var requestEncoding = contentType.Encoding ?? Encoding.UTF8; var requestWrapper = await requestReader.GetRequestWrapper(context, requestEncoding); await requestHandler.HandleRequest(context, requestWrapper, requestEncoding, next); log.LogTrace($"Completed"); }