Bumped package version to 1.1.6 and removed RouteListenerContext in favor of built in HttpListenerContext since it's already apart of .Net. Cleaned up code and build passes.

This commit is contained in:
2023-02-02 09:51:34 -08:00
parent 7dcc28d5e0
commit cd6dd40fe2
8 changed files with 59 additions and 92 deletions

View File

@ -34,12 +34,12 @@ namespace MontoyaTech.Rest.Net.Example
new Route(HttpRequestMethod.Get, "/json", Json)
);
listener.RequestPreProcessEvent += (RouteListenerContext context) => {
listener.RequestPreProcessEvent += (HttpListenerContext context) => {
Console.WriteLine("Request start: " + context.Request.RawUrl);
return true;
};
listener.RequestPostProcessEvent += (RouteListenerContext context) =>
listener.RequestPostProcessEvent += (HttpListenerContext context) =>
{
Console.WriteLine("Request end: " + context.Request.RawUrl);
};
@ -56,22 +56,22 @@ namespace MontoyaTech.Rest.Net.Example
listener.Block();
}
public static HttpListenerResponse Status(RouteListenerContext context)
public static HttpListenerResponse Status(HttpListenerContext context)
{
return context.Response.WithStatus(HttpStatusCode.OK).WithText("Everything is operational. 👍");
}
public static HttpListenerResponse Add(RouteListenerContext context, double a, double b)
public static HttpListenerResponse Add(HttpListenerContext context, double a, double b)
{
return context.Response.WithStatus(HttpStatusCode.OK).WithText((a + b).ToString());
}
public static HttpListenerResponse Signup(RouteListenerContext context, User user)
public static HttpListenerResponse Signup(HttpListenerContext context, User user)
{
return context.Response.WithStatus(HttpStatusCode.OK).WithText("User:" + user.Name);
}
public static HttpListenerResponse Json(RouteListenerContext context)
public static HttpListenerResponse Json(HttpListenerContext context)
{
return context.Response.WithStatus(HttpStatusCode.OK).WithJson(new User("Rest.Net"));
}