-
-
Notifications
You must be signed in to change notification settings - Fork 167
/
TestModule.cs
46 lines (40 loc) · 1.77 KB
/
TestModule.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
namespace Botwin.Tests
{
using System.Linq;
using Botwin.Request;
using Microsoft.AspNetCore.Http;
public class TestModule : BotwinModule
{
public TestModule()
{
this.Before = async (ctx) =>
{
await ctx.Response.WriteAsync("Before");
return true;
};
this.After = async (ctx) => { await ctx.Response.WriteAsync("After"); };
this.Get("/", async (ctx) => { await ctx.Response.WriteAsync("Hello"); });
this.Get("/querystring", async ctx =>
{
var id = ctx.Request.Query.As<int>("id");
await ctx.Response.WriteAsync($"Managed to parse an int {id}");
});
this.Get("/multiquerystring", async ctx =>
{
var id = ctx.Request.Query.AsMultiple<int>("id");
await ctx.Response.WriteAsync($"Managed to parse multiple ints {id.Count()}");
});
this.Get("/querystringdefault", async ctx =>
{
var id = ctx.Request.Query.As<int>("id", 69);
await ctx.Response.WriteAsync($"Managed to parse default int {id}");
});
this.Post("/", async (ctx) => { await ctx.Response.WriteAsync("Hello"); });
this.Put("/", async (ctx) => { await ctx.Response.WriteAsync("Hello"); });
this.Delete("/", async (ctx) => { await ctx.Response.WriteAsync("Hello"); });
this.Head("/head", async (ctx) => { await ctx.Response.WriteAsync("Hello"); });
this.Patch("/", async (ctx) => { await ctx.Response.WriteAsync("Hello"); });
this.Options("/", async (ctx) => { await ctx.Response.WriteAsync("Hello"); });
}
}
}