Skip to content

Commit ca5409f

Browse files
committed
add documents about request & response for java/groovy
1 parent a378543 commit ca5409f

File tree

2 files changed

+281
-225
lines changed

2 files changed

+281
-225
lines changed

More.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,42 @@
11
3. More about Nginx-Clojure
22
=================
33

4+
5+
3.0 More about APIs
6+
-----------------
7+
8+
### Request & Response
9+
10+
For Clojure the request map and response map are defined by the ring SEPC at https://github.com/ring-clojure/ring/blob/master/SPEC .
11+
12+
For Java/Groovy , the reqest map contains serveral parts:
13+
14+
1. server-port (Required, Integer) The port on which the request is being handled.
15+
1. server-name (Required, String) The resolved server name, or the server IP address.
16+
1. remote-addr (Required, String) The IP address of the client or the last proxy that sent the request.
17+
1. uri (Required, String) The request URI, excluding the query string and the "?" separator. Must start with "/".
18+
1. query-string (Optional, String) The query string, if present.
19+
1. scheme (Required, String) The transport protocol, must be one of http or https.
20+
1. request-method (Required, String) The HTTP request method, must be a lowercase keyword corresponding to a HTTP request method, such as :get or :post.
21+
1. content-type **DEPRECATED** (Optional, String)The MIME type of the request body, if known.
22+
1. content-length **DEPRECATED** (Optional, Integer) The number of bytes in the request body, if known.
23+
1. character-encoding **DEPRECATED** (Optional, String) The name of the character encoding used in the request body, if known.
24+
1. sl-client-cert (Optional, X509Certificate) The SSL client certificate, if supplied. This value is not **supported** yet.
25+
1. headers (Required, Map) A map of header name Strings to corresponding header value Strings.
26+
1. body (Optional, InputStream) An InputStream for the request body, if present.
27+
28+
The return response is an array of object, e.g
29+
30+
```java
31+
32+
[200, //http status 200
33+
ArrayMap.create("Content-Type", "text/html", "", "" ), //headers map
34+
"Hello, Java & Nginx!" //response body can be string, File or Array/Collection of string or File ];
35+
```
36+
37+
>Note that If the rewrite/access handler returns phrase-done (Clojure) or Constants.PHRASE_DONE (Groovy/Java), nginx will continue to next phases (e.g. invoke proxy_pass or content ring handler). If the rewrite handler returns a general response, nginx will send this response to the client and stop to continue to next phases.
38+
39+
440
3.1 Handle Multiple Coroutine Based Sockets Parallel
541
-----------------
642

0 commit comments

Comments
 (0)