ln.http/router/HttpRoutingContext.cs

32 lines
941 B
C#
Raw Normal View History

2020-03-03 17:13:31 +01:00
using System;
namespace ln.http.router
{
public class HttpRoutingContext
{
public HttpRequest HttpRequest { get; }
public string Path { get; set; }
public string RoutedPath { get; set; }
public HttpRoutingContext(HttpRequest httpRequest) : this(httpRequest, httpRequest.URI.AbsolutePath) { }
public HttpRoutingContext(HttpRequest httpRequest, string path)
{
HttpRequest = httpRequest;
Path = path;
RoutedPath = "";
}
HttpRoutingContext(HttpRequest httpRequest,string path,string routedPath)
{
HttpRequest = httpRequest;
Path = path;
RoutedPath = routedPath;
}
public HttpRoutingContext Routed(string residual)
{
return new HttpRoutingContext(HttpRequest, residual, RoutedPath + Path.Substring(0,Path.Length - residual.Length));
}
}
}