11using System ;
2- using System . Linq ;
3- using System . Net ;
42using System . Text . Json ;
53using System . Threading ;
64using System . Threading . Tasks ;
75
86using WatsonWebserver ;
7+ using WatsonWebserver . Core ;
98
109namespace Benchmarks
1110{
@@ -23,7 +22,7 @@ public class JsonResult
2322
2423 public static class Program
2524 {
26- private static readonly ManualResetEvent _WaitEvent = new ManualResetEvent ( false ) ;
25+ private static readonly ManualResetEvent WaitEvent = new ( false ) ;
2726
2827 public static async Task < int > Main ( string [ ] args )
2928 {
@@ -33,21 +32,23 @@ public static async Task<int> Main(string[] args)
3332 var host = "tfb-server" ;
3433#endif
3534
36- using var server = new Server ( host , 8080 , false , DefaultRoute ) ;
35+ var settings = new WebserverSettings ( host , 8080 , false ) ;
3736
38- server . Routes . Static . Add ( HttpMethod . GET , "/plaintext" , PlaintextRoute ) ;
39- server . Routes . Static . Add ( HttpMethod . GET , "/json" , JsonRoute ) ;
37+ using var server = new Webserver ( settings , DefaultRoute ) ;
38+
39+ server . Routes . PreAuthentication . Static . Add ( HttpMethod . GET , "/plaintext" , PlaintextRoute ) ;
40+ server . Routes . PreAuthentication . Static . Add ( HttpMethod . GET , "/json" , JsonRoute ) ;
4041
4142 try
4243 {
4344 AppDomain . CurrentDomain . ProcessExit += ( _ , __ ) =>
4445 {
45- _WaitEvent . Set ( ) ;
46+ WaitEvent . Set ( ) ;
4647 } ;
4748
4849 await server . StartAsync ( ) ;
4950
50- _WaitEvent . WaitOne ( ) ;
51+ WaitEvent . WaitOne ( ) ;
5152
5253 return 0 ;
5354 }
@@ -59,22 +60,21 @@ public static async Task<int> Main(string[] args)
5960 }
6061 }
6162
62- static async Task DefaultRoute ( HttpContext ctx )
63+ static async Task DefaultRoute ( HttpContextBase ctx )
6364 {
6465 ctx . Response . StatusCode = 404 ;
65- ctx . Response . StatusDescription = "Not Found" ;
6666
6767 await ctx . Response . Send ( "Not found." ) ;
6868 }
6969
70- static async Task PlaintextRoute ( HttpContext ctx )
70+ static async Task PlaintextRoute ( HttpContextBase ctx )
7171 {
7272 ctx . Response . Headers . Add ( "Content-Type" , "text/plain; charset=UTF-8" ) ;
7373
7474 await ctx . Response . Send ( "Hello, World!" ) ;
7575 }
7676
77- static async Task JsonRoute ( HttpContext ctx )
77+ static async Task JsonRoute ( HttpContextBase ctx )
7878 {
7979 var response = new JsonResult ( ) { Message = "Hello, World!" } ;
8080 var serialized = JsonSerializer . Serialize ( response ) ;
0 commit comments