-
Notifications
You must be signed in to change notification settings - Fork 64
/
router.ex
48 lines (38 loc) · 1.76 KB
/
router.ex
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
defmodule RigInboundGatewayWeb.Router do
use RigInboundGatewayWeb, :router
pipeline :api do
plug(Plug.Logger, log: :debug)
plug(Rig.Plug.AuthHeader)
end
scope "/_rig", RigInboundGatewayWeb do
pipe_through(:api)
get("/health", HealthController, :check_health)
scope "/v1", V1 do
scope "/connection/sse" do
subscription_url = "/:connection_id/subscriptions"
options(subscription_url, SubscriptionController, :handle_preflight)
put(subscription_url, SubscriptionController, :set_subscriptions)
# The SSE handler is implemented using Cowboy's loop handler behaviour and set
# up using the Cowboy dispatch configuration; see the `config.exs` file.
end
# Unlike SSE & WS handlers, the LP handler is implemented using plug
scope "/connection/longpolling" do
subscription_url = "/:connection_id/subscriptions"
get("/", LongpollingController, :handle_connection)
options("/", LongpollingController, :handle_preflight)
options(subscription_url, SubscriptionController, :handle_preflight)
put(subscription_url, SubscriptionController, :set_subscriptions)
end
scope "/connection/ws" do
subscription_url = "/:connection_id/subscriptions"
options(subscription_url, SubscriptionController, :handle_preflight)
put(subscription_url, SubscriptionController, :set_subscriptions)
# The WebSocket handler is implemented using Cowboy's loop handler behaviour and set
# up using the Cowboy dispatch configuration; see the `config.exs` file.
end
options("/events", EventController, :handle_preflight)
post("/events", EventController, :publish)
end
end
forward("/", RigInboundGateway.ApiProxy.Plug)
end