Getting Started
Stop talking and show me the code !
Installation
Using the SimpleW nuget package, always prefer the last version.
sh
$ dotnet add package SimpleWMinimal Example
The following minimal example can be used for rapid prototyping :
csharp
using System;
using System.Net;
using SimpleW;
namespace Sample {
class Program {
static void Main() {
// listen to all IPs port 2015
var server = new SimpleWServer(IPAddress.Any, 2015);
// minimal api
server.MapGet("/api/test", () => {
return new { message = "Hello World !" };
});
// start non blocking background server
server.Start();
Console.WriteLine("server started at http://localhost:2015/");
// block console for debug
Console.ReadKey();
}
}
}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
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
NOTE
While this example is perfect for rapid prototyping, it lacks proper organization. Take a look at the basic of organizing your code following the Controller pattern.
