Added ReadAsForm to the RequestExtensions to help with reading form data. Bumped package verison to 1.6.0

This commit is contained in:
2023-06-09 14:53:41 -07:00
parent efd744974d
commit 52a6db9e1a
3 changed files with 29 additions and 2 deletions

View File

@ -82,7 +82,8 @@ namespace MontoyaTech.Rest.Net.Example
new Route(HttpRequestMethod.Get, "/auth/", Json),
new Route(HttpRequestMethod.Get, "/auth/role", GetRole),
new Route(HttpRequestMethod.Post, "/upload", Upload),
new Route(HttpRequestMethod.Get, "/download", Download)
new Route(HttpRequestMethod.Get, "/download", Download),
new Route(HttpRequestMethod.Post, "/form", FormTest)
);
string code = listener.GenerateCSharpClient();
@ -224,5 +225,12 @@ namespace MontoyaTech.Rest.Net.Example
{
return context.Response.WithStatus(HttpStatusCode.OK).WithText("Hello world");
}
[RouteGroup("Form")]
[RouteResponse(typeof(Dictionary<string, string>))]
public static HttpListenerResponse FormTest(HttpListenerContext context)
{
return context.Response.WithStatus(HttpStatusCode.OK).WithJson(context.Request.ReadAsForm());
}
}
}