Working on a client code generation feature to help speed up using an api built with this library.
This commit is contained in:
@ -34,6 +34,10 @@ namespace MontoyaTech.Rest.Net.Example
|
||||
new Route(HttpRequestMethod.Get, "/json", Json)
|
||||
);
|
||||
|
||||
Console.WriteLine(CodeGenerator.GenerateCSharpClient(listener.Routes));
|
||||
|
||||
Console.ReadLine();
|
||||
|
||||
listener.RequestPreProcessEvent += (HttpListenerContext context) => {
|
||||
Console.WriteLine("Request start: " + context.Request.RawUrl);
|
||||
return true;
|
||||
@ -56,21 +60,25 @@ namespace MontoyaTech.Rest.Net.Example
|
||||
listener.Block();
|
||||
}
|
||||
|
||||
[RouteGroup("Test")]
|
||||
public static HttpListenerResponse Status(HttpListenerContext context)
|
||||
{
|
||||
return context.Response.WithStatus(HttpStatusCode.OK).WithText("Everything is operational. 👍");
|
||||
}
|
||||
|
||||
[RouteGroup("Test")]
|
||||
public static HttpListenerResponse Add(HttpListenerContext context, double a, double b)
|
||||
{
|
||||
return context.Response.WithStatus(HttpStatusCode.OK).WithText((a + b).ToString());
|
||||
}
|
||||
|
||||
[RouteGroup("Test")]
|
||||
public static HttpListenerResponse Signup(HttpListenerContext context, User user)
|
||||
{
|
||||
return context.Response.WithStatus(HttpStatusCode.OK).WithText("User:" + user.Name);
|
||||
}
|
||||
|
||||
[RouteGroup("Test")]
|
||||
public static HttpListenerResponse Json(HttpListenerContext context)
|
||||
{
|
||||
return context.Response.WithStatus(HttpStatusCode.OK).WithJson(new User("Rest.Net"));
|
||||
|
Reference in New Issue
Block a user