/
SaberParameterHandler.ns2
52 lines (38 loc) · 1.93 KB
/
SaberParameterHandler.ns2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
Newsqueak2
'Saber'
class SaberParameterHandler = (
"
A Handler for RESTful parameters in a request url.
For example:
given the following SiteRoot
SiteRoot << SaberHandler
SiteRoot`Foo << SaberHandler
SiteRoot`Bar << SaberHandler
SiteRoot`Bar`Baz << SaberHandler
SiteRoot`Bar`Blah << SaberParameterHandler
SiteRoot`Bar`Blah`Feh << SaberHandler
a request for '/foo/bar/baz' will return the Baz SaberHandler, but what about a request for '/foo/bar/username/feh' ? In this case, since there is no handler matching the 'username' node, but there *is* a parameter handler, we would 'dive' into Blah, (assigning the value of 'username' to the request with the #Blah key) and then match on the Feh SaberHandler.
Essentially, a SaberParameterHandler will act as a 'catch-all' handler if and only if none of the actual handler classes nested in a handler are matched. The value of the node that was not matched will be stored in request as a string, using the class name of the class subclassing SaberParameterHandler as the key. As such, don't have duplicate parameter names in a hierarchy.
Aside from this unique routing behavior at request-time, a SaberParameterHandler behaves exactly like a SaberHandler.
Copyright 2009 Jeff Olson
Licensed under the Apache License, Version 2.0 (the 'License'); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
"
|
|
)
('as yet unclassified'
onDelete: request = (
^ '404'
)
onGet: request = (
^ '404'
)
onPost: request = (
^ '404'
)
onPut: request = (
^ '404'
)
)