1 /*
2  * Archttp - A highly performant web framework written in D.
3  *
4  * Copyright (C) 2021-2022 Kerisy.com
5  *
6  * Website: https://www.kerisy.com
7  *
8  * Licensed under the Apache-2.0 License.
9  *
10  */
11 
12 module archttp.HttpContext;
13 
14 import archttp.HttpRequest;
15 import archttp.HttpResponse;
16 
17 import gear.codec.Framed;
18 
19 alias Framed!(HttpRequest, HttpResponse) HttpFramed;
20 
21 class HttpContext
22 {
23     private HttpRequest _request;
24     private HttpResponse _response;
25     private HttpFramed _framed;
26     
27     this(HttpFramed framed)
28     {
29         _framed = framed;
30     }
31 
32     HttpRequest request() {
33         return _request;
34     }
35 
36     void request(HttpRequest request)
37     {
38         _request = request;
39     }
40 
41     HttpResponse response()
42     {
43         if (_response is null)
44             _response = new HttpResponse(this);
45 
46         return _response;
47     }
48 
49     void response(HttpResponse response)
50     {
51         _response = response;
52     }
53 
54     void Send(HttpResponse response)
55     {
56         _framed.Send(response);
57     }
58 
59     void End()
60     {
61         // _connection.Close();
62     }
63 }