Simplified some class names and structure. New nuget version 1.1.4

This commit is contained in:
2023-01-26 11:48:56 -08:00
parent 6db21454c9
commit 9b849f5ec1
8 changed files with 52 additions and 53 deletions

View File

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