public virtual async Task Handle(HttpContext context, ServiceEntry serviceEntry) { Check.NotNull(context, nameof(context)); Check.NotNull(serviceEntry, nameof(serviceEntry)); var requestParameters = await _parameterParser.Parser(context.Request, serviceEntry); RpcContext.GetContext().SetAttachment("requestHeader", requestParameters[ParameterFrom.Header]); var rpcParameters = serviceEntry.ResolveParameters(requestParameters); string serviceKey = null; if (context.Request.Headers.ContainsKey("serviceKey")) { serviceKey = context.Request.Headers["serviceKey"].ToString(); RpcContext.GetContext().SetAttachment("serviceKey", serviceKey); } RpcContext.GetContext().SetAttachment("token", _rpcOptions.Token); var excuteResult = await _serviceExecutor.Execute(serviceEntry, rpcParameters, serviceKey); context.Response.ContentType = "application/json;charset=utf-8"; context.Response.StatusCode = 200; if (excuteResult != null) { var responseData = _serializer.Serialize(excuteResult); context.Response.ContentLength = responseData.GetBytes().Length; await context.Response.WriteAsync(responseData); } else { context.Response.ContentLength = 0; await context.Response.WriteAsync(string.Empty); } }
public List <BatteryParameters> Parser(List <string> parameters) { return(_parser.Parser(parameters)); }