-
Notifications
You must be signed in to change notification settings - Fork 4
/
webrouting_service.clj
141 lines (115 loc) · 6.21 KB
/
webrouting_service.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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
(ns puppetlabs.trapperkeeper.services.webrouting.webrouting-service
(:require
[puppetlabs.trapperkeeper.core :refer [defservice]]
[puppetlabs.trapperkeeper.services :refer [service-context]]
[puppetlabs.trapperkeeper.services.webrouting.webrouting-service-core :as core]))
(defprotocol WebroutingService
(get-route [this svc] [this svc route-id])
(get-server [this svc] [this svc route-id])
(add-context-handler [this svc context-path] [this svc context-path options])
(add-ring-handler [this svc handler] [this svc handler options])
(add-servlet-handler [this svc servlet] [this svc servlet options])
(add-websocket-handler [this svc handlers] [this svc handlers options])
(add-war-handler [this svc war] [this svc war options])
(add-proxy-route [this svc target] [this svc target options])
(override-webserver-settings! [this overrides] [this server-id overrides])
(get-registered-endpoints [this] [this server-id])
(log-registered-endpoints [this] [this server-id])
(join [this] [this server-id]))
(defservice webrouting-service
"Provides the ability to route handlers to different jetty10 webserver services"
WebroutingService
[WebserverService
[:ConfigService get-in-config]]
(init [this context]
(let [config (get-in-config [:web-router-service])]
(when (nil? config)
(throw (IllegalArgumentException.
":web-router-service section of configuration not present")))
(core/init context config)))
(get-route [this svc]
(core/get-route (service-context this) svc nil))
(get-route [this svc route-id]
(core/get-route (service-context this) svc route-id))
(get-server [this svc]
(core/get-server (service-context this) svc nil))
(get-server [this svc route-id]
(core/get-server (service-context this) svc route-id))
(add-context-handler [this svc base-path]
(core/add-context-handler! (service-context this)
WebserverService svc
base-path {}))
(add-context-handler [this svc base-path options]
(core/add-context-handler! (service-context this)
WebserverService svc
base-path options))
(add-ring-handler [this svc handler]
(core/add-ring-handler! (service-context this)
WebserverService svc
handler {}))
(add-ring-handler [this svc handler options]
(core/add-ring-handler! (service-context this)
WebserverService svc
handler options))
(add-servlet-handler [this svc servlet]
(core/add-servlet-handler! (service-context this)
WebserverService svc
servlet {}))
(add-servlet-handler [this svc servlet options]
(core/add-servlet-handler! (service-context this)
WebserverService svc
servlet options))
(add-websocket-handler [this svc handlers]
(core/add-websocket-handler! (service-context this)
WebserverService svc
handlers {}))
(add-websocket-handler [this svc handlers options]
(core/add-websocket-handler! (service-context this)
WebserverService svc
handlers options))
(add-war-handler [this svc war]
(core/add-war-handler! (service-context this)
WebserverService svc
war {}))
(add-war-handler [this svc war options]
(core/add-war-handler! (service-context this)
WebserverService svc
war options))
(add-proxy-route [this svc target]
(core/add-proxy-route! (service-context this)
WebserverService svc
target {}))
(add-proxy-route [this svc target options]
(core/add-proxy-route! (service-context this)
WebserverService svc
target options))
(override-webserver-settings! [this overrides]
(let [override-webserver-settings
(:override-webserver-settings! WebserverService)]
(override-webserver-settings overrides)))
(override-webserver-settings! [this server-id overrides]
(let [override-webserver-settings
(:override-webserver-settings! WebserverService)]
(override-webserver-settings server-id overrides)))
(get-registered-endpoints [this]
(let [get-registered-endpoints
(:get-registered-endpoints WebserverService)]
(get-registered-endpoints)))
(get-registered-endpoints [this server-id]
(let [get-registered-endpoints
(:get-registered-endpoints WebserverService)]
(get-registered-endpoints server-id)))
(log-registered-endpoints [this]
(let [log-registered-endpoints
(:log-registered-endpoints WebserverService)]
(log-registered-endpoints)))
(log-registered-endpoints [this server-id]
(let [log-registered-endpoints
(:log-registered-endpoints WebserverService)]
(log-registered-endpoints server-id)))
(join [this]
(let [join (:join WebserverService)]
(join)))
(join [this server-id]
(let [join (:join WebserverService)]
(join server-id))))