|
1 | 1 | 3. More about Nginx-Clojure
|
2 | 2 | =================
|
3 | 3 |
|
| 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 | + |
4 | 40 | 3.1 Handle Multiple Coroutine Based Sockets Parallel
|
5 | 41 | -----------------
|
6 | 42 |
|
|
0 commit comments