1+ using System ;
2+ using System . Buffers . Text ;
3+ using System . Net ;
4+ using System . Threading . Tasks ;
5+ using SimpleW ;
6+
7+ namespace Benchmarks ;
8+
9+ internal static class Program
10+ {
11+ public static async Task Main ( string [ ] args )
12+ {
13+ var server = new SimpleWServer ( IPAddress . Any , 8080 ) ;
14+ server . AddDynamicContent ( "/api" ) ;
15+ server . Start ( ) ;
16+
17+ await Task . Delay ( - 1 ) ;
18+ }
19+
20+ public class BenchmarksController : Controller {
21+ [ Route ( "GET" , "/json" ) ]
22+ public object Json ( ) {
23+ return Response . MakeResponse (
24+ new { message = "Hello, World!" } , // object will be serialized
25+ addHeaders : new Dictionary < string , string > ( )
26+ {
27+ { "Server" , "SimpleW" } ,
28+ { "Date" , DateTime . Now . ToString ( "R" ) }
29+ }
30+ // compress parameter is default to null, so no compression
31+ ) ;
32+ }
33+
34+ [ Route ( "GET" , "/plaintext" ) ]
35+ public object Plaintext ( ) {
36+ return Response . MakeResponse (
37+ "Hello, World!" ,
38+ "text/plain" ,
39+ addHeaders : new Dictionary < string , string > ( )
40+ {
41+ { "Server" , "SimpleW" } ,
42+ { "Date" , DateTime . Now . ToString ( "R" ) }
43+ }
44+ // compress parameter is default to null, so no compression
45+ ) ;
46+ }
47+ }
48+ }
0 commit comments