You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/index.md
+13-13Lines changed: 13 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -42,21 +42,21 @@ If you know how to write a monadic, result-returning APL function, you're ready
42
42
43
43
1. Next, create an instance of `Jarvis` using `Jarvis.New`.
44
44
45
-
```
46
-
j←Jarvis.New ''
47
-
```
48
-
This will create a `Jarvis` instance with all settings set to their default values. By default, `Jarvis` will use port 8080 and look for your endpoint code in `#`.
45
+
j←Jarvis.New ''
46
+
47
+
This will create a `Jarvis` instance with all settings set to their default values. By default, `Jarvis` will use port 8080 and look for your endpoint code in `#`.
49
48
50
49
1. You can now run your web service running on port 8080 and serving code from the # (root) namespace.
2024-09-06 @ 15.46.24.221 - Local Conga v3.5 reference is #.Jarvis.[LIB]
56
+
2024-09-06 @ 15.46.24.231 - Jarvis starting in "JSON" mode on port 8080
57
+
2024-09-06 @ 15.46.24.232 - Serving code in #
58
+
2024-09-06 @ 15.46.24.237 - Click http://192.168.001.123:8080 to access web interface
59
+
```
60
60
61
61
If the server started successfully, you'll see messages similar to those above displayed to the APL session and the return code `rc` should be `0` and `msg` should be empty. If there was any problem starting `Jarvis`, `rc` will be non-`0` and `msg` will contain a (hopefully) helpful message about the problem that occurred.
Copy file name to clipboardExpand all lines: docs/rest.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,9 +9,9 @@ Rather than writing a function for each endpoint as in the JSON paradigm, you wi
9
9
10
10
You specify which HTTP methods your REST service will support using the [`RESTMethods`](settings-rest.md#restmethods) setting. For instance, setting `RESTMethods←'Get'` indicates that your service will support only HTTP GET requests. Such requests will call the `#.CodeLocation.Get` function, passing the HTTP request as its right argument. For the purposes of this document, we'll call the request right argument `Request`.
11
11
12
-
Your `Get` function would then look at the resource being requested by parsing [`Request.Endpoint`](httprequest.md#endpoint) element. If [`DefaultContentType`](settings-operational.md#defaultcontenttype) is set to `'application/json'` (the default), your function can return an APL array which `Jarvis` will convert to JSON. If you are not using `'application/json'`, then you will need to:
12
+
Your `Get` function would then look at the resource being requested by parsing [`Request.Endpoint`](request.md#endpoint) element. If [`DefaultContentType`](settings-operational.md#defaultcontenttype) is set to `'application/json'` (the default), your function can return an APL array which `Jarvis` will convert to JSON. If you are not using `'application/json'`, then you will need to:
13
13
14
-
1. use [`Request.SetContentType`](httprequest.md#contenttype) to set an appropriate content type
14
+
1. use [`Request.SetContentType`](request.md#contenttype) to set an appropriate content type
15
15
2. set the `Request.Response.Payload` to the content you want to send back to the client
16
16
17
17
### The client sends a request
@@ -32,7 +32,7 @@ When `Jarvis` receives the request, it verifies that the request is well-formed.
32
32
### `Jarvis` calls your method function
33
33
`Jarvis` passes the [`Request`](./reference.md#request) object as the right argument to the function appropriate for the HTTP method being used. It is up to your function to parse `Request.Endpoint` to determine the resource being requested. As noted above, if the response payload's `content-type` is `'application/json'` your function can return an APL array which `Jarvis` will automatically convert to JSON. Otherwise, your function is responsible for setting the `Request.Response.Payload` and `Request.ContentType` appropriately.
34
34
35
-
If the requested resource is not found, or some other issue occurs, your function should fail the request with an appropriate HTTP status code using [`Request.Fail`](./httprequest.md#fail). For example, an HTTP status code of 404 means that the requested resource was not found and you would use `Request.Fall 404` to set the status code.
35
+
If the requested resource is not found, or some other issue occurs, your function should fail the request with an appropriate HTTP status code using [`Request.Fail`](request.md#fail). For example, an HTTP status code of 404 means that the requested resource was not found and you would use `Request.Fall 404` to set the status code.
36
36
37
37
!!! tip "Advanced Usage"
38
38
**Jarvis** has a few specific places where you can "inject" your own APL code to perform actions like additional request validation, authentication, and so on. Two such places are available after `Jarvis` receives the request, but before calling your function. These are:
Copy file name to clipboardExpand all lines: docs/settings-hooks.md
+8Lines changed: 8 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -20,6 +20,14 @@
20
20
|Examples|`j.AuthenticateFn←'Authenticate'`|
21
21
|Notes|See [Authentication](./security.md#authentication) for more information about how to authenticate an HTTP request.|
22
22
23
+
### `PostProcessFn`
24
+
|--|--|
25
+
|Description|`PostProcessFn` is the name of monadic, non-result-returning function to be called *after* your endpoint has run but *before* the response is sent to the client. The right argument to the function is the [`Request`](./request.md) instance. The function should not return a result however, if it does, that result is ignored.<br>If you have some treatment that you need to apply to every response, `PostProcessFn` can be used to avoid having to add that treatment to every endpoint.|
26
+
|Default|`''`|
27
+
|Examples|`j.PostProcessFn←'PostProcess'`<br><br>   `∇ PostProcess req`<br>`[1] 'custom-header'req.SetHeader'some value' ⍝ add a custom header`<br>`[2] req.Reponse.Payload.Message←'Have a nice day!' ⍝ modify the payload`<br>   `∇`|
28
+
29
+
30
+
23
31
### `SessionInitFn`
24
32
|--|--|
25
33
|Description|`SessionInitFn` is the name of a monadic, result-returning function that can perform session initialization if your web service is using sessions. The right argument is the [`Request`](./request.md) instance, which we'll call `req`. The reference to the session namespace is `req.Session`. The integer function result should be either:<ul><li>`0` - indicating that the session was successfully initialized</li><li>non-`0` - indicating session initialization failed; in which case `Jarvis` will fail the request with an HTTP status code of 500 ().</li></ul>|
Copy file name to clipboardExpand all lines: docs/settings-json.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -31,4 +31,4 @@ These settings apply when using **Jarvis**'s JSON paradigm.
31
31
|Description|When a requested endpoint is not found, `Jarvis` will always respond by setting the response HTTP status code to `404` and HTTP status message to `'Not Found'`. `Report404InHTML` controls whether `Jarvis` will also return a simple "not found" HTML page in its response payload. This is potentially useful when the client is a web browser. Valid settings are:<ul><li>`1` - return a simple HTML page in the response payload indicating the requested endpoint was not found. This is useful when the client connecting to `Jarvis` is a web browser.</li><li>`0` - Do not return any information in the response payload.|
32
32
|Default|`1`|
33
33
|Examples|`j.Report404←0 ⍝ disable sending the "not found" HTML page`|
34
-
|Notes|`Report404InHTML` has effect only if the [`HTMLInterface`](.settings-json.md) is enabled.|
34
+
|Notes|`Report404InHTML` has effect only if the [`HTMLInterface`](#htmlinterface) is enabled.|
0 commit comments