Esempio n. 1
0
        public async Task Invoke(HttpContext httpContext)
        {
            if (httpContext.Request.Path.HasValue)
            {
                var endpoint = httpContext.Request.Path.Value;
                if (endpoint == OmniSharpEndpoints.CheckAliveStatus)
                {
                    MiddlewareHelpers.WriteTo(httpContext.Response, true);
                    return;
                }

                if (endpoint == OmniSharpEndpoints.CheckReadyStatus)
                {
                    MiddlewareHelpers.WriteTo(httpContext.Response, _workspace.Initialized);
                    return;
                }
            }

            await _next(httpContext);
        }
Esempio n. 2
0
        public async Task Invoke(HttpContext httpContext)
        {
            if (httpContext.Request.Path.HasValue)
            {
                var endpoint = httpContext.Request.Path.Value;
                if (_endpoints.Contains(endpoint))
                {
                    if (_endpointHandlers.TryGetValue(endpoint, out var handler))
                    {
                        var response = await handler.Value.Handle(new RequestPacket()
                        {
                            Command         = endpoint,
                            ArgumentsStream = httpContext.Request.Body
                        });

                        MiddlewareHelpers.WriteTo(httpContext.Response, response);
                        return;
                    }
                }
            }

            await _next(httpContext);
        }