File tree Expand file tree Collapse file tree 3 files changed +18
-12
lines changed Expand file tree Collapse file tree 3 files changed +18
-12
lines changed Original file line number Diff line number Diff line change @@ -2,11 +2,22 @@ use web, fastcgi
2
2
3
3
import web/[Application, Request]
4
4
import fastcgi/Server
5
+ import structs/HashMap
5
6
6
7
7
8
HelloApplication : class extends Application {
8
9
parseRequest : func (request : Request ) {
9
10
"Request path: %s" format (request path) println ()
11
+ "Request method: %s" format (request method) println ()
12
+ "Request remote addr: %s port %d" format (request remoteAddress, request remotePort) println ()
13
+ }
14
+
15
+ sendHeaders : func (headers : HashMap < String > ) {
16
+ headers["Content-type" ] = "text/html"
17
+ }
18
+
19
+ sendResponse : func (writer : ResponseWriter ) {
20
+ writer write ("<html>" ). write ("<body>" ). write ("<h1>Hello!</h1>" ). write ("</body></html>" )
10
21
}
11
22
}
12
23
Original file line number Diff line number Diff line change @@ -3,11 +3,11 @@ import web/Request
3
3
import structs/HashMap
4
4
5
5
ResponseWriter : abstract class {
6
- write : func (data : String ) -> Int { return 0 }
7
- flush : func {}
6
+ write : abstract func (data : String ) -> Int
7
+ flush : abstract func
8
8
}
9
9
10
- Application : abstract class {
10
+ Application : class {
11
11
parseRequest : func (request : Request ) {}
12
12
sendHeaders : func (headers : HashMap < String > ) {}
13
13
sendResponse : func (writer : ResponseWriter ) {}
Original file line number Diff line number Diff line change 1
- import structs/HashMap
2
-
3
- Request : class {
4
- init : func {
5
- headers = HashMap< String> new ()
6
- }
7
-
1
+ Request : abstract class {
8
2
path : String
9
3
method : String
4
+ remoteAddress : String
10
5
remoteHost : String
11
- remotePort : Int
6
+ remotePort : String
12
7
13
- headers : HashMap < String >
8
+ getHeader : abstract func ( name : String ) -> String
14
9
}
15
10
You can’t perform that action at this time.
0 commit comments