ApiManagementConsoleV2.RoutePolicies (api_management_console v0.2.0)

Copy Markdown View Source

Route policy management for enabling/disabling endpoints.

Backed by DETS for persistence. Routes are keyed as "method|path" (e.g. "get|/api/users"). Some routes are immutable (protected) and cannot be toggled — configured via :api_management_console, :protected_routes.

Supports string prefixes/suffixes and regex patterns (matched against path and controller):

config :api_management_console,
  protected_routes: ["/dev/dashboard", ~r{HealthController}]

Summary

Functions

Adds keys to the selection atomically.

Returns a specification to start this module under a supervisor.

Check if a path belongs to the API console itself.

Check if a route is enabled by key.

Returns the current route selection as a MapSet of route keys.

Checks if a key is in the current selection.

Returns all routes as a flat list.

Returns routes grouped by namespace, with enabled state and mutable flag.

Removes keys from the selection atomically.

Check if a request (method + path) is allowed.

Reset all policies — delete DETS file.

Returns the count of selected routes.

Toggle all mutable routes in a group. Returns [{key, old_state}].

Toggle a single route by key. Returns the old state.

Sets the route selection atomically.

Functions

add_to_selection(keys)

Adds keys to the selection atomically.

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

console_route?(path)

Check if a path belongs to the API console itself.

enabled?(key)

Check if a route is enabled by key.

get_selection()

Returns the current route selection as a MapSet of route keys.

in_selection?(key)

Checks if a key is in the current selection.

list_all_routes(router)

Returns all routes as a flat list.

list_grouped_routes(router)

Returns routes grouped by namespace, with enabled state and mutable flag.

remove_from_selection(keys)

Removes keys from the selection atomically.

request_allowed?(router, method, path)

Check if a request (method + path) is allowed.

reset_all()

Reset all policies — delete DETS file.

selection_count()

Returns the count of selected routes.

set_group_enabled(router, group, enabled)

Toggle all mutable routes in a group. Returns [{key, old_state}].

set_route_enabled(route_key, enabled)

Toggle a single route by key. Returns the old state.

set_selection(keys)

Sets the route selection atomically.