private void HandleHttpRequest(HttpRequestReceivedEventArgs e) { try { HttpRequestReceived?.Invoke(this, e); } finally { if (_webSocketClientSession == null) { if (!e.IsHandled || e.Context.Request.Headers.GetConnectionMustBeClosed()) { _cancellationTokenSource.Cancel(); } } } }
private void HandleHttpRequest(object sender, HttpRequestReceivedEventArgs eventArgs) { var handlerCollection = RequestReceived; if (handlerCollection == null) { return; } foreach (var handler in handlerCollection.GetInvocationList()) { handler.DynamicInvoke(this, eventArgs); if (eventArgs.IsHandled) { return; } } }
private void ProcessHttpRequest(HttpContext context) { try { var eventArgs = new HttpRequestReceivedEventArgs(context); _httpRequestReceivedCallback(eventArgs); if (!eventArgs.IsHandled) { context.Response.StatusCode = HttpStatusCode.NotFound; } } catch (Exception exception) { if (context != null) { context.Response.StatusCode = HttpStatusCode.InternalServerError; context.Response.Body = new JsonBody(JsonSerializer.SerializeException(exception)); } } }
private void ExecuteActions(object sender, HttpRequestReceivedEventArgs e) { string requestUri = e.Context.Request.Uri.Trim('/'); if (!requestUri.StartsWith(_baseUri, StringComparison.OrdinalIgnoreCase)) { return; } string relativeUri = requestUri.Substring(_baseUri.Length).Trim('/'); foreach (var handler in _handlers) { if (!handler.Method.Equals(e.Context.Request.Method)) { continue; } if (handler.HandleRequestsWithDifferentSubUrl) { if (!relativeUri.StartsWith(handler.Uri)) { continue; } } else { if (!handler.Uri.Equals(relativeUri)) { continue; } } InvokeHandlerAction(handler, e.Context); e.IsHandled = true; return; } }
private void DispatchHttpRequest(object sender, HttpRequestReceivedEventArgs eventArgs) { if (!eventArgs.Context.Request.Uri.StartsWith("/api/")) { return; } eventArgs.IsHandled = true; DispatchHttpRequest(eventArgs.Context); }