using ln.http.router; namespace ln.http { public class HttpContext { public HTTPServer HttpServer { get; } public HttpRequest Request { get; set; } public HttpResponse Response { get; set; } public HttpPrincipal AuthenticatedPrincipal { get; private set; } public HttpContext(HTTPServer httpServer) { HttpServer = httpServer; } public HttpContext(HTTPServer httpServer, HttpRequest httpRequest) : this(httpServer) { Request = httpRequest; RoutableUri = httpRequest.RequestUri.AbsolutePath; } public string RoutableUri { get; set; } public bool Authenticate(HttpAuthenticationDelegate authenticationDelegate) { if (authenticationDelegate(this, out HttpPrincipal principal)) { AuthenticatedPrincipal = principal; return true; } return false; } public void DeAuthenticate() => AuthenticatedPrincipal = null; } }