forked from juice-shop/juice-shop
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathweb.cs
41 lines (34 loc) · 986 Bytes
/
web.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
using System;
using System.Net;
using System.Net.Http;
using System.Web.Http;
public class GreetingController : ApiController
{
[HttpGet]
[Route("api/serviceStack")]
public HttpResponseMessage Get()
{
var response = Request.CreateResponse(HttpStatusCode.OK, "Hello, System.Web.Http API!");
return response;
}
}
public class Program
{
public static void Main(string[] args)
{
var config = new HttpConfiguration();
config.MapHttpAttributeRoutes();
var server = new HttpServer(config);
using (var listener = new HttpListener())
{
listener.Prefixes.Add("http://localhost:8080/");
listener.Start();
Console.WriteLine("API server is running. Listening on http://localhost:8080/");
while (true)
{
var context = listener.GetContext();
server.ProcessRequestAsync(context).Wait();
}
}
}
}