index.community/backend/lib/backend_web/router.ex
2020-05-27 14:08:04 +01:00

30 lines
817 B
Elixir

defmodule BackendWeb.Router do
use BackendWeb, :router
import BackendWeb.RateLimiter
pipeline :api do
plug(:accepts, ["json"])
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)
end
scope "/api", BackendWeb do
pipe_through(:api)
resources("/instances", InstanceController, only: [:index, :show])
resources("/graph", GraphController, only: [:index, :show])
resources("/search", SearchController, only: [:index])
scope "/admin" do
pipe_through :api_admin
resources("/login", AdminLoginController, only: [:show, :create])
get "/", AdminController, :show
post "/", AdminController, :update
end
end
end