source: binary-improvements2/WebServer/src/RequestContext.cs@ 419

Last change on this file since 419 was 415, checked in by alloc, 21 months ago

Added HTTP method to RequestContext

File size: 1.1 KB
Line 
1using SpaceWizards.HttpListener;
2
3namespace Webserver {
4 public enum ERequestMethod {
5 Other,
6 // ReSharper disable InconsistentNaming
7 GET,
8 PUT,
9 POST,
10 DELETE,
11 HEAD,
12 OPTIONS,
13 // ReSharper restore InconsistentNaming
14 Count
15 }
16
17 public class RequestContext {
18 public string RequestPath;
19 public readonly ERequestMethod Method;
20 public readonly HttpListenerRequest Request;
21 public readonly HttpListenerResponse Response;
22 public readonly WebConnection Connection;
23 public readonly int PermissionLevel;
24
25 public RequestContext (string _requestPath, HttpListenerRequest _request, HttpListenerResponse _response, WebConnection _connection, int _permissionLevel) {
26 RequestPath = _requestPath;
27 Request = _request;
28 Response = _response;
29 Connection = _connection;
30 PermissionLevel = _permissionLevel;
31 Method = _request.HttpMethod switch {
32 "GET" => ERequestMethod.GET,
33 "PUT" => ERequestMethod.PUT,
34 "POST" => ERequestMethod.POST,
35 "DELETE" => ERequestMethod.DELETE,
36 "HEAD" => ERequestMethod.HEAD,
37 "OPTIONS" => ERequestMethod.OPTIONS,
38 _ => ERequestMethod.Other
39 };
40 }
41 }
42}
Note: See TracBrowser for help on using the repository browser.