Skip to content

Commit 694de26

Browse files
committed
HashMap -> HeaderMap
1 parent f5bcc08 commit 694de26

File tree

4 files changed

+25
-7
lines changed

4 files changed

+25
-7
lines changed

examples/dispatch.ooc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@ use web, fastcgi
22

33
import web/[Application, Dispatcher]
44
import fastcgi/Server
5-
import structs/HashMap
65

76

87
RootApplication: class extends Application {
9-
sendHeaders: func(headers: HashMap<String>) {
8+
sendHeaders: func(headers: HeaderMap) {
109
headers["Content-type"] = "text/plain"
1110
}
1211
}

examples/hello.ooc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ use web, fastcgi
22

33
import web/[Application, Request]
44
import fastcgi/Server
5-
import structs/HashMap
65

76

87
HelloApplication: class extends Application {
@@ -12,7 +11,7 @@ HelloApplication: class extends Application {
1211
"Request remote addr: %s port %d" format(request remoteAddress, request remotePort) println()
1312
}
1413

15-
sendHeaders: func(headers: HashMap<String>) {
14+
sendHeaders: func(headers: HeaderMap) {
1615
headers["Content-type"] = "text/html"
1716
}
1817

web/Application.ooc

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,31 @@ ResponseWriter: abstract class {
77
flush: abstract func
88
}
99

10+
HeaderMap: class extends HashMap<String> {
11+
init: func ~headermap {
12+
init(1)
13+
}
14+
15+
init: func ~headermapWithCapacity (capacity: UInt) {
16+
T = String
17+
super(capacity)
18+
}
19+
}
20+
21+
operator [] <T> (map: HeaderMap, key: String) -> T {
22+
map get(key)
23+
}
24+
25+
operator []= <T> (map: HeaderMap, key: String, value: T) {
26+
map put(key, value)
27+
}
28+
29+
1030
Application: class {
1131
request: Request
1232

1333
parseRequest: func {}
14-
sendHeaders: func(headers: HashMap<String>) {}
34+
sendHeaders: func(headers: HeaderMap) {}
1535
sendResponse: func(response: ResponseWriter) {}
1636
}
1737

web/Dispatcher.ooc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use web
22
import web/Application
3-
import structs/[LinkedList, HashMap]
3+
import structs/LinkedList
44

55

66
/**
@@ -21,7 +21,7 @@ Dispatcher: class extends Application {
2121
}
2222
}
2323

24-
sendHeaders: func(headers: HashMap<String>) {
24+
sendHeaders: func(headers: HeaderMap) {
2525
for (app: Application in applications) {
2626
app sendHeaders(headers)
2727
}

0 commit comments

Comments
 (0)