analytics/lib/plausible_web/router.ex

149 lines
6.2 KiB
Elixir
Raw Normal View History

2019-09-02 14:29:19 +03:00
defmodule PlausibleWeb.Router do
use PlausibleWeb, :router
use Plug.ErrorHandler
use Sentry.Plug
@two_weeks_in_seconds 60 * 60 * 24 * 14
pipeline :browser do
plug :accepts, ["html"]
plug :fetch_session
plug :fetch_flash
plug :put_secure_browser_headers
plug PlausibleWeb.SessionTimeoutPlug, timeout_after_seconds: @two_weeks_in_seconds
plug PlausibleWeb.AuthPlug
plug PlausibleWeb.LastSeenPlug
end
pipeline :csrf do
plug :protect_from_forgery
end
2019-09-02 14:29:19 +03:00
pipeline :api do
2019-12-03 12:42:17 +03:00
plug :accepts, ["json"]
2019-09-02 14:29:19 +03:00
plug :fetch_session
plug PlausibleWeb.AuthPlug
end
pipeline :stats_api do
plug :accepts, ["json"]
plug :fetch_session
end
2019-09-02 14:29:19 +03:00
if Mix.env == :dev do
forward "/sent-emails", Bamboo.SentEmailViewerPlug
end
scope "/api/stats", PlausibleWeb.Api do
pipe_through :stats_api
get "/:domain/current-visitors", StatsController, :current_visitors
get "/:domain/main-graph", StatsController, :main_graph
get "/:domain/referrers", StatsController, :referrers
get "/:domain/goal/referrers", StatsController, :referrers_for_goal
get "/:domain/referrers/:referrer", StatsController, :referrer_drilldown
get "/:domain/goal/referrers/:referrer", StatsController, :referrer_drilldown_for_goal
get "/:domain/pages", StatsController, :pages
get "/:domain/countries", StatsController, :countries
get "/:domain/browsers", StatsController, :browsers
get "/:domain/operating-systems", StatsController, :operating_systems
get "/:domain/screen-sizes", StatsController, :screen_sizes
get "/:domain/conversions", StatsController, :conversions
end
2019-09-02 14:29:19 +03:00
scope "/api", PlausibleWeb do
pipe_through :api
2019-10-31 06:49:46 +03:00
post "/event", Api.ExternalController, :event
post "/unload", Api.ExternalController, :unload
2019-09-02 14:29:19 +03:00
get "/error", Api.ExternalController, :error
post "/paddle/webhook", Api.PaddleController, :webhook
get "/:domain/status", Api.InternalController, :domain_status
end
scope "/", PlausibleWeb do
pipe_through :browser
get "/register", AuthController, :register_form
post "/register", AuthController, :register
get "/claim-activation", AuthController, :claim_activation_link
get "/login", AuthController, :login_form
post "/login", AuthController, :login
get "/password/request-reset", AuthController, :password_reset_request_form
post "/password/request-reset", AuthController, :password_reset_request
get "/password/reset", AuthController, :password_reset_form
post "/password/reset", AuthController, :password_reset
end
scope "/", PlausibleWeb do
pipe_through [:browser, :csrf]
2019-09-02 14:29:19 +03:00
get "/password", AuthController, :password_form
post "/password", AuthController, :set_password
post "/logout", AuthController, :logout
get "/settings", AuthController, :user_settings
put "/settings", AuthController, :save_settings
delete "/me", AuthController, :delete_me
get "/auth/google/callback", AuthController, :google_auth_callback
get "/", PageController, :index
get "/privacy", PageController, :privacy
get "/terms", PageController, :terms
get "/data-policy", PageController, :data_policy
get "/feedback", PageController, :feedback
get "/roadmap", PageController, :roadmap
get "/contact", PageController, :contact_form
post "/contact", PageController, :submit_contact_form
get "/billing/change-plan", BillingController, :change_plan_form
get "/billing/change-plan/preview/:plan_id", BillingController, :change_plan_preview
post "/billing/change-plan/:new_plan_id", BillingController, :change_plan
2019-09-02 14:29:19 +03:00
get "/billing/upgrade", BillingController, :upgrade
get "/billing/success", BillingController, :success
2020-03-31 16:16:21 +03:00
get "/sites", SiteController, :index
2019-09-02 14:29:19 +03:00
get "/sites/new", SiteController, :new
post "/sites", SiteController, :create_site
post "/sites/:website/make-public", SiteController, :make_public
post "/sites/:website/make-private", SiteController, :make_private
2019-09-09 14:37:57 +03:00
post "/sites/:website/weekly-report/enable", SiteController, :enable_weekly_report
post "/sites/:website/weekly-report/disable", SiteController, :disable_weekly_report
post "/sites/:website/weekly-report/recipients", SiteController, :add_weekly_report_recipient
delete "/sites/:website/weekly-report/recipients/:recipient", SiteController, :remove_weekly_report_recipient
2019-09-09 14:37:57 +03:00
post "/sites/:website/monthly-report/enable", SiteController, :enable_monthly_report
post "/sites/:website/monthly-report/disable", SiteController, :disable_monthly_report
post "/sites/:website/monthly-report/recipients", SiteController, :add_monthly_report_recipient
delete "/sites/:website/monthly-report/recipients/:recipient", SiteController, :remove_monthly_report_recipient
get "/sites/:website/shared-links/new", SiteController, :new_shared_link
post "/sites/:website/shared-links", SiteController, :create_shared_link
delete "/sites/:website/shared-links/:slug", SiteController, :delete_shared_link
get "/sites/:website/custom-domains/new", SiteController, :new_custom_domain
get "/sites/:website/custom-domains/dns-setup", SiteController, :custom_domain_dns_setup
get "/sites/:website/custom-domains/snippet", SiteController, :custom_domain_snippet
post "/sites/:website/custom-domains", SiteController, :add_custom_domain
get "/sites/:website/weekly-report/unsubscribe", UnsubscribeController, :weekly_report
get "/sites/:website/monthly-report/unsubscribe", UnsubscribeController, :monthly_report
2019-09-02 14:29:19 +03:00
get "/:website/snippet", SiteController, :add_snippet
get "/:website/settings", SiteController, :settings
2019-10-31 08:39:51 +03:00
get "/:website/goals", SiteController, :goals
get "/:website/goals/new", SiteController, :new_goal
post "/:website/goals", SiteController, :create_goal
2019-10-31 09:20:45 +03:00
delete "/:website/goals/:id", SiteController, :delete_goal
2019-09-02 14:29:19 +03:00
put "/:website/settings", SiteController, :update_settings
put "/:website/settings/google", SiteController, :update_google_auth
2019-09-02 14:29:19 +03:00
delete "/:website", SiteController, :delete_site
get "/share/:slug", StatsController, :shared_link
post "/share/:slug/authenticate", StatsController, :authenticate_shared_link
get "/:domain/visitors.csv", StatsController, :csv_export
get "/:domain/*path", StatsController, :stats
2019-09-02 14:29:19 +03:00
end
end