Skip to content

Commit 183120c

Browse files
author
Eric Redmond
committed
build up flow spec
1 parent fcbd3f5 commit 183120c

File tree

9 files changed

+835
-829
lines changed

9 files changed

+835
-829
lines changed

lib/flow.iced

Lines changed: 0 additions & 582 deletions
This file was deleted.

lib/fsm.iced

Lines changed: 583 additions & 10 deletions
Large diffs are not rendered by default.
Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1+
12
class ReqData
23
constructor: (nodeReq, urlForm, pathInfo)->
34
@req = nodeReq
45
@url = urlForm
56
@pathInfo = pathInfo
67
@method = nodeReq.method
7-
@disp_path = null
8+
@dispPath = null
89

910
## request functions
1011

@@ -18,34 +19,34 @@ class ReqData
1819

1920
# -> string() The “local” path of the resource URI; the part after any prefix
2021
# 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
2223
# is called in your resource.
23-
disp_path: ()-> @url.pathname
24+
dispPath: ()-> @url.pathname
2425

2526
# -> string() The path part of the URI – after the host and port, but not
2627
# including any query string.
2728
path: ()-> @url.pathname
2829

2930
# -> string() The entire path part of the URI, including any query string present.
30-
raw_path: ()-> @url.path
31+
rawPath: ()-> @url.path
3132

3233
# -> 'undefined', string() Looks up a binding as described in dispatch configuration.
3334
# -> 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
3536

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('/')
3839

3940
# -> 'undefined', string() Look up the value of an incoming request header.
40-
get_req_header: (field)-> @req_headers()[field]
41+
getReqHeader: (field)-> @reqHeaders()[field]
4142

42-
# -> mochiheaders() The incoming HTTP headers. Generally, get_req_header is more useful.
43+
# -> mochiheaders() The incoming HTTP headers. Generally, getReqHeader is more useful.
4344
# TODO: downcase?
44-
req_headers: ()-> @req.headers
45+
reqHeaders: ()-> @req.headers
4546

4647
# TODO: it'd be nice to make this blocking. but, whatever
4748
# -> 'undefined', binary() The incoming request body, if any.
48-
# req_body: ()->
49+
# reqBody: ()->
4950
# # parse the body
5051
# body = ""
5152
# console.log "waiting"
@@ -59,40 +60,40 @@ class ReqData
5960

6061
# -> streambody() The incoming request body in streamed form, passing in a
6162
# callback function.
62-
# stream_req_body
63-
req_body: (cb)->
63+
# streamReqBody
64+
reqBody: (cb)->
6465
body = ""
6566
@req.on "data", (chunk)->
6667
body += chunk.toString()
6768
@req.on "end", ()->
6869
cb(body)
6970

7071
# -> string() Look up the named value in the incoming request cookie header.
71-
get_cookie_value: (string)->
72+
getCookieValue: (string)->
7273

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
7475
# often more useful.
75-
req_cookie: ()->
76+
reqCookie: ()->
7677
# TODO: parse this
77-
@get_req_header('cookie')
78+
@getReqHeader('cookie')
7879

7980
# -> 'undefined', string() Given the name of a key, look up the corresponding
8081
# value in the query string.
8182
# -> string() Given the name of a key and a default value if not present, look
8283
# up the corresponding value in the query string.
83-
get_qs_value: (string, defaultValue)->
84+
getQsValue: (string, defaultValue)->
8485
if defaultValue
8586
@url.query[string] || defaultValue
8687
else
8788
@url.query[string]
8889

8990
# -> [{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
9293

9394
# -> string() Indicates the “height” above the requested URI that this resource
9495
# is dispatched from. Typical values are “.” , “..” , “../..” and so on.
95-
app_root: ()->
96+
appRoot: ()->
9697
"."
9798

9899
module.exports = ReqData

lib/resource.iced

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1+
12
class Resource
23
constructor: (config)->
34
@route = config.route
45
@config = config
5-
@known_methods = ['GET']
6+
@knownMethods = ['GET']
67

78

8-
# service_available: function(req, res, next) ->
9-
# next(200) unless @config?service_available
9+
# serviceAvailable: function(req, res, next) ->
10+
# next(200) unless @config?serviceAvailable
1011

11-
# finish_request: function(req, res, next) ->
12-
# next(false) unless @config?service_available
12+
# finishRequest: function(req, res, next) ->
13+
# next(false) unless @config?serviceAvailable

lib/response_data.iced renamed to lib/responseData.iced

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,58 +4,58 @@ class ResData
44
@res = nodeRes
55
@headers = {}
66

7-
is_redirect: ()->
7+
isRedirect: ()->
88

9-
append_to_response_body: (body)->
9+
appendToResponseBody: (body)->
1010

1111
# -> string() Look up the current value of an outgoing request header.
12-
get_resp_header: (string)->
12+
getRespHeader: (string)->
1313
@res.getHeader(string)
1414

1515
statusCode: ()->
1616
@res.statusCode
1717

18-
# -> bool() the last value passed to do_redirect, false otherwise – if true,
18+
# -> bool() the last value passed to doRedirect, false otherwise – if true,
1919
# then some responses will be 303 instead of 2xx where applicable
20-
resp_redirect: ()->
20+
respRedirect: ()->
2121

22-
# -> mochiheaders() The outgoing HTTP headers. Generally, get_resp_header is
22+
# -> mochiheaders() The outgoing HTTP headers. Generally, getRespHeader is
2323
# more useful.
24-
resp_headers: ()->
24+
respHeaders: ()->
2525

2626
# -> 'undefined', binary() The outgoing response body, if one has been set.
27-
# Usually, append_to_response_body is the best way to set this.
28-
resp_body: ()->
27+
# Usually, appendToResponseBody is the best way to set this.
28+
respBody: ()->
2929

30-
has_response_body: ()->
30+
hasResponseBody: ()->
3131

3232
## Request Modification Functions
3333

3434
# rd() Given a header name and value, set an outgoing request header to that value.
35-
set_resp_header: (string, value) ->
35+
setRespHeader: (string, value) ->
3636

3737
# rd() Append the given value to the body of the outgoing response.
38-
append_to_response_body: (binary) ->
38+
appendToResponseBody: (binary) ->
3939

40-
# rd() see resp_redirect; this sets that value.
41-
do_redirect: (bool) ->
40+
# rd() see respRedirect; this sets that value.
41+
doRedirect: (bool) ->
4242

43-
# rd() The disp_path is the only path that can be changed during a request. This function will do so.
44-
set_disp_path: (string) ->
43+
# rd() The dispPath is the only path that can be changed during a request. This function will do so.
44+
setDispPath: (string) ->
4545

4646
# rd() Replace the incoming request body with this for the rest of the processing.
47-
set_req_body: (binary) ->
47+
setReqBody: (binary) ->
4848

4949
# rd() Set the outgoing response body to this value.
50-
set_resp_body: (binary) ->
50+
setRespBody: (binary) ->
5151

5252
# rd() Use this streamed body to produce the outgoing response body on demand.
53-
set_resp_body: (streambody) ->
53+
setRespBody: (streambody) ->
5454

5555
# rd() Given a list of two-tuples of {headername,value}, set those outgoing response headers.
56-
set_resp_headers: (headername, value) ->
56+
setRespHeaders: (headername, value) ->
5757

5858
# rd() Remove the named outgoing response header.
59-
remove_resp_header: (string) ->
59+
removeRespHeader: (string) ->
6060

6161
module.exports = ResData

0 commit comments

Comments
 (0)