File: begin-handler.2gg

package info (click to toggle)
golf 601.4.41-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,824 kB
  • sloc: ansic: 20,020; sh: 1,171; makefile: 292
file content (75 lines) | stat: -rw-r--r-- 2,757 bytes parent folder | download
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
.TH GOLF 2gg $VERSION $DATE Development Tools
.SH NAME
begin-handler \-  (service-processing)
.SH PURPOSE
Define a request handler.

.SH SYNTAX

.RS 4
.EX

begin-handler <request path> [ private | public ]
    <any code>
end-handler

.EE
.RE

.SH DESCRIPTION
begin-handler starts the implementation of a \fBrequest\fP handler for <request path> (see \fBrequest\fP), which is <any code> up to end-handler. <request path> is not quoted.

A <request path> is a path consisting of any number of path segments. A request path can have alphanumeric characters, hyphens and forward slashes, and can start only with a forward slash.

For example, a <request path> can be "/wine-items" or "/items/wine" etc. In general, it represents the nature of a request, such as an action on an object, a resource path handled by it etc. There is no specific way to interpret a request path, and you can construct it in a way that works for you.

The source ".golf" file name that implements a given begin-handler matches its path and name, fully or partially (see \fBrequest\fP). For example, <request path> of "/items/wine" might be implemented in  "items/wine.golf" file (meaning in file "wine.golf" in subdirectory "items").

Note that you can also use "%%" instead of either begin-handler or end-handler or both. A <request path> cannot be a C reserved word, such as for instance "main" or "typedef" etc.

.LP
.B SECURITY OF REQUEST CALLS
.LP

If "public" clause is used, then a handler can be called from an outside caller, be it a web browser, some web service, \fBservice\fP call or \fBcommand-line\fP program. 

If "private" clause is used, then a handler cannot be called from an outside caller; it can only be called from another handler by using \fBcall-handler\fP statement. 

If neither "public" nor "private" is used, then the default is "private". This default mechanism automatically guards direct execution by outside callers of all handlers not marked "public"; it provides automatic safety guard. 

You can change this default behavior with "--public" option in \fBgg\fP, in which case the default is "public". This is useful if either all request handlers should be public, or if only a handful fixed ones are private.

.SH EXAMPLES
The following begin-handler is implemented in file "items/wines/red-wine.golf":

.RS 4
.EX

begin-handler  /items/wines/red-wine public
    @This is a request handler to display a list of red wines!
end-handler

.EE
.RE

Another way to write this is:

.RS 4
.EX

%%  /items/wines/red-wine public
    @This is a request handler to display a list of red wines!
%%

.EE
.RE

.SH SEE ALSO
 Service processing

\fBafter-handler\fP  
\fBbefore-handler\fP  
\fBbegin-handler\fP  
\fBcall-handler\fP   
See all 
\fBdocumentation\fP