2019-07-14 11:47:06 +00:00
|
|
|
defmodule BackendWeb.Router do
|
|
|
|
use BackendWeb, :router
|
2020-05-19 16:39:33 +00:00
|
|
|
import BackendWeb.RateLimiter
|
2019-07-14 11:47:06 +00:00
|
|
|
|
|
|
|
pipeline :api do
|
2019-07-23 12:20:34 +00:00
|
|
|
plug(:accepts, ["json"])
|
2020-05-19 16:39:33 +00:00
|
|
|
plug(:rate_limit, max_requests: 5, interval_seconds: 10) # requests to the same endpoint
|
|
|
|
end
|
|
|
|
|
|
|
|
pipeline :api_admin do
|
|
|
|
plug(:rate_limit_authentication, max_requests: 5, interval_seconds: 60)
|
2019-07-14 11:47:06 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
scope "/api", BackendWeb do
|
2019-07-23 12:20:34 +00:00
|
|
|
pipe_through(:api)
|
2019-07-14 11:47:06 +00:00
|
|
|
|
2019-08-27 13:50:16 +00:00
|
|
|
resources("/instances", InstanceController, only: [:index, :show])
|
2019-07-23 16:32:43 +00:00
|
|
|
resources("/graph", GraphController, only: [:index, :show])
|
2019-07-23 12:20:34 +00:00
|
|
|
resources("/search", SearchController, only: [:index])
|
2019-07-26 14:34:23 +00:00
|
|
|
|
2020-05-19 16:39:33 +00:00
|
|
|
scope "/admin" do
|
|
|
|
pipe_through :api_admin
|
|
|
|
|
|
|
|
resources("/login", AdminLoginController, only: [:show, :create])
|
|
|
|
get "/", AdminController, :show
|
|
|
|
post "/", AdminController, :update
|
|
|
|
end
|
2019-07-14 11:47:06 +00:00
|
|
|
end
|
|
|
|
end
|