Bonfire.Web.Router (Bonfire v1.0.2-social-rc.10)

Copy Markdown View Source

Summary

Functions

Used to serve the GraphiQL API browser

Callback invoked by Plug on every request.

(re)generates the reverse router (useful so it can be re-generated when extensions are enabled/disabled)

Used to serve GraphQL API queries

Callback required by Plug that initializes the router for serving web requests.

Rate limit plug for controllers.

Wraps protect_from_forgery to gracefully handle stale CSRF tokens by renewing the session and redirecting back.

Functions

absinthe_before_send(conn, blueprint)

account_required(conn, _)

activity_json(conn, _)

activity_json_or_html(conn, _)

admin_required(conn, _)

api_browser(conn, _)

Used to serve the GraphiQL API browser

authorize(conn, opts)

basic(conn, _)

basic_html(conn, _)

basic_json(conn, _)

browser(conn, _)

browser_accepts(conn, _)

browser_or_cacheable(conn, _)

browser_render(conn, _)

browser_security(conn, _)

browser_ui(conn, _)

browser_unsafe(conn, _)

cacheable(conn, _)

cacheable_page(conn, _)

cacheable_post_public(conn, _)

call(conn, opts)

Callback invoked by Plug on every request.

check_provider_enabled(conn, opts)

early_hints_authed(conn, _)

formatted_routes(_)

Callback implementation for Phoenix.VerifiedRoutes.formatted_routes/1.

generate_reverse_router!(app \\ :bonfire)

(re)generates the reverse router (useful so it can be re-generated when extensions are enabled/disabled)

graphql(conn, _)

Used to serve GraphQL API queries

guest_only(conn, _)

host_meta(conn, _)

html_only(conn, _)

init(opts)

Callback required by Plug that initializes the router for serving web requests.

load_authorization(conn, opts)

load_current_auth(conn, _)

masto_api(conn, _)

rate_limit(conn, opts)

Rate limit plug for controllers.

Reads configuration from Application.get_env(:bonfire, :rate_limit)[key_prefix] with fallback to default options provided in the plug call.

Options

  • :key_prefix - Atom prefix for the rate limit bucket key (required)
  • :scale_ms - Default time window in milliseconds (can be overridden by config)
  • :limit - Default number of requests (can be overridden by config)
  • :method - Optional HTTP method to rate limit (e.g., "POST"). If provided, only requests
            with this method will be rate limited. All other methods pass through.

Examples

# Rate limit all requests
plug :rate_limit, 
  key_prefix: :api,
  scale_ms: 60_000,
  limit: 100

# Rate limit only POST requests (form submissions)
plug :rate_limit, 
  key_prefix: :forms,
  scale_ms: 60_000,
  limit: 5,
  method: "POST"

require_authenticated_user(conn, _)

require_confirmed(conn, _)

safe_protect_from_forgery(conn, opts)

Wraps protect_from_forgery to gracefully handle stale CSRF tokens by renewing the session and redirecting back.

set_locale(conn, opts)

signed_activity_pub_fetch(conn, _)

signed_activity_pub_incoming(conn, _)

static_generator(conn, _)

throttle_forms(conn, _)

user_required(conn, _)

verified_route?(_, split_path)

Callback implementation for Phoenix.VerifiedRoutes.verified_route?/2.

webfinger(conn, _)

well_known_nodeinfo(conn, _)