Added compressed response extensions and added more to the example program. Bumped package version to 1.3.3
This commit is contained in:
@ -4,6 +4,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Net;
|
||||
using System.IO;
|
||||
using MontoyaTech.Rest.Net;
|
||||
using System.Net.Mime;
|
||||
|
||||
@ -29,9 +30,13 @@ namespace MontoyaTech.Rest.Net.Example
|
||||
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
File.WriteAllText("test.txt", "hello from a file");
|
||||
|
||||
var listener = new RouteListener(8080,
|
||||
new Route(HttpRequestMethod.Get, "/status", Status),
|
||||
new Route<double, double>(HttpRequestMethod.Post, "/add/{a}/{b}", Add),
|
||||
new Route(HttpRequestMethod.Get, "/compress", Compress),
|
||||
new Route(HttpRequestMethod.Get, "/file/compress", CompressFile),
|
||||
new Route<string>(HttpRequestMethod.Get, "/auth/{username}", Exists),
|
||||
new Route(HttpRequestMethod.Post, "/auth/signup", Signup),
|
||||
new Route(HttpRequestMethod.Get, "/auth/", Json)
|
||||
@ -90,6 +95,19 @@ namespace MontoyaTech.Rest.Net.Example
|
||||
return context.Response.WithStatus(HttpStatusCode.OK).WithText((a + b).ToString());
|
||||
}
|
||||
|
||||
[RouteGroup("Test")]
|
||||
[RouteResponse(typeof(string))]
|
||||
public static HttpListenerResponse Compress(HttpListenerContext context)
|
||||
{
|
||||
return context.Response.WithStatus(HttpStatusCode.OK).WithCompressedText("hello world");
|
||||
}
|
||||
|
||||
[RouteGroup("Test")]
|
||||
[RouteResponse(typeof(string))]
|
||||
public static HttpListenerResponse CompressFile(HttpListenerContext context)
|
||||
{
|
||||
return context.Response.WithStatus(HttpStatusCode.OK).WithCompressedFile("test.txt");
|
||||
}
|
||||
|
||||
[RouteGroup("Test")]
|
||||
[RouteRequest(typeof(User))]
|
||||
|
Reference in New Issue
Block a user