1
+
1
2
class ReqData
2
3
constructor : (nodeReq , urlForm , pathInfo )->
3
4
@req = nodeReq
4
5
@url = urlForm
5
6
@pathInfo = pathInfo
6
7
@method = nodeReq .method
7
- @disp_path = null
8
+ @dispPath = null
8
9
9
10
# # request functions
10
11
@@ -18,34 +19,34 @@ class ReqData
18
19
19
20
# -> string() The “local” path of the resource URI; the part after any prefix
20
21
# used in dispatch configuration. Of the three path accessors, this is the
21
- # one you usually want. This is also the one that will change after create_path
22
+ # one you usually want. This is also the one that will change after createPath
22
23
# is called in your resource.
23
- disp_path : ()-> @url .pathname
24
+ dispPath : ()-> @url .pathname
24
25
25
26
# -> string() The path part of the URI – after the host and port, but not
26
27
# including any query string.
27
28
path : ()-> @url .pathname
28
29
29
30
# -> string() The entire path part of the URI, including any query string present.
30
- raw_path : ()-> @url .path
31
+ rawPath : ()-> @url .path
31
32
32
33
# -> 'undefined', string() Looks up a binding as described in dispatch configuration.
33
34
# -> any() The dictionary of bindings as described in dispatch configuration.
34
- path_info : (field )-> if field then @pathInfo [field] else @pathInfo
35
+ pathInfo : (field )-> if field then @pathInfo [field] else @pathInfo
35
36
36
- # -> list() This is a list of string() terms, the disp_path components split by “/”.
37
- path_tokens : ()-> @ disp_path ().split (' /' )
37
+ # -> list() This is a list of string() terms, the dispPath components split by “/”.
38
+ pathTokens : ()-> @ dispPath ().split (' /' )
38
39
39
40
# -> 'undefined', string() Look up the value of an incoming request header.
40
- get_req_header : (field )-> @ req_headers ()[field]
41
+ getReqHeader : (field )-> @ reqHeaders ()[field]
41
42
42
- # -> mochiheaders() The incoming HTTP headers. Generally, get_req_header is more useful.
43
+ # -> mochiheaders() The incoming HTTP headers. Generally, getReqHeader is more useful.
43
44
# TODO: downcase?
44
- req_headers : ()-> @req .headers
45
+ reqHeaders : ()-> @req .headers
45
46
46
47
# TODO: it'd be nice to make this blocking. but, whatever
47
48
# -> 'undefined', binary() The incoming request body, if any.
48
- # req_body : ()->
49
+ # reqBody : ()->
49
50
# # parse the body
50
51
# body = ""
51
52
# console.log "waiting"
@@ -59,40 +60,40 @@ class ReqData
59
60
60
61
# -> streambody() The incoming request body in streamed form, passing in a
61
62
# callback function.
62
- # stream_req_body
63
- req_body : (cb )->
63
+ # streamReqBody
64
+ reqBody : (cb )->
64
65
body = " "
65
66
@req .on " data" , (chunk )->
66
67
body += chunk .toString ()
67
68
@req .on " end" , ()->
68
69
cb (body)
69
70
70
71
# -> string() Look up the named value in the incoming request cookie header.
71
- get_cookie_value : (string )->
72
+ getCookieValue : (string )->
72
73
73
- # -> string() The raw value of the cookie header. Note that get_cookie_value is
74
+ # -> string() The raw value of the cookie header. Note that getCookieValue is
74
75
# often more useful.
75
- req_cookie : ()->
76
+ reqCookie : ()->
76
77
# TODO: parse this
77
- @ get_req_header (' cookie' )
78
+ @ getReqHeader (' cookie' )
78
79
79
80
# -> 'undefined', string() Given the name of a key, look up the corresponding
80
81
# value in the query string.
81
82
# -> string() Given the name of a key and a default value if not present, look
82
83
# up the corresponding value in the query string.
83
- get_qs_value : (string , defaultValue )->
84
+ getQsValue : (string , defaultValue )->
84
85
if defaultValue
85
86
@url .query [string] || defaultValue
86
87
else
87
88
@url .query [string]
88
89
89
90
# -> [{string(), string()}] The parsed query string, if any. Note that
90
- # get_qs_value is often more useful.
91
- req_qs : ()-> @url .query
91
+ # getQsValue is often more useful.
92
+ reqQs : ()-> @url .query
92
93
93
94
# -> string() Indicates the “height” above the requested URI that this resource
94
95
# is dispatched from. Typical values are “.” , “..” , “../..” and so on.
95
- app_root : ()->
96
+ appRoot : ()->
96
97
" ."
97
98
98
99
module .exports = ReqData
0 commit comments