-
Notifications
You must be signed in to change notification settings - Fork 297
/
request.clj
88 lines (78 loc) · 2.33 KB
/
request.clj
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
76
77
78
79
80
81
82
83
84
85
86
87
88
; Copyright 2014-2019 Cognitect, Inc.
; The use and distribution terms for this software are covered by the
; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0)
; which can be found in the file epl-v10.html at the root of this distribution.
;
; By using this software in any fashion, you are agreeing to be bound by
; the terms of this license.
;
; You must not remove this notice, or any other, from this software.
(ns io.pedestal.http.request)
(defprotocol ProxyDatastructure
(realized [this] "Return fully-realized version of underlying data structure."))
(extend-protocol ProxyDatastructure
nil
(realized [t] nil))
(defprotocol ContainerRequest
(server-port [x])
(server-name [x])
(remote-addr [x])
(uri [x])
(query-string [x])
(scheme [x])
(request-method [x])
(protocol [x])
(headers [x])
(header [x header-string])
(ssl-client-cert [x])
(body [x])
(path-info [x])
(async-supported? [x])
(async-started? [x]))
(extend-protocol ContainerRequest
nil
(server-port [x] nil)
(server-name [x] nil)
(remote-addr [x] nil)
(uri [x] nil)
(query-string [x] nil)
(scheme [x] nil)
(request-method [x] nil)
(protocol [x] nil)
(headers [x] nil)
(header [x header-string] nil)
(ssl-client-cert [x] nil)
(body [x] nil)
(path-info [x] nil)
(async-supported? [x] false)
(async-started? [x] false))
(defprotocol ResponseBuffer
(response-buffer-size [x]))
(def ring-dispatch
{:server-port server-port
:server-name server-name
:remote-addr remote-addr
:uri uri
:query-string query-string
:scheme scheme
:request-method request-method
:headers headers
:ssl-client-cert ssl-client-cert
:body body
:path-info path-info
:protocol protocol
:async-supported? async-supported?})
(def nil-fn (constantly nil))
(defn base-request-map [req]
{:server-port (server-port req)
:server-name (server-name req)
:remote-addr (remote-addr req)
:uri (uri req)
:query-string (query-string req)
:scheme (scheme req)
:request-method (request-method req)
:headers (headers req)
:body (body req)
:path-info (path-info req)
:protocol (protocol req)
:async-supported? (async-supported? req)})