CampaignFlow.MockServer.Handlers.Helpers (CampaignFlow Client v2.2.0)
View SourceShared helpers for mock server HTTP handlers: bearer auth, integer path-param parsing, and the like. Keeps individual handler modules free of boilerplate.
Summary
Functions
Parses a path-param string as an integer. Returns {:ok, int} for a
fully-numeric value, :error otherwise.
Wraps a handler function with a bearer-auth check. The function is
invoked only if the request has a non-empty Authorization: Bearer ...
header; otherwise a 401 is sent.
Functions
Parses a path-param string as an integer. Returns {:ok, int} for a
fully-numeric value, :error otherwise.
@spec with_auth(Plug.Conn.t(), (-> Plug.Conn.t())) :: Plug.Conn.t()
Wraps a handler function with a bearer-auth check. The function is
invoked only if the request has a non-empty Authorization: Bearer ...
header; otherwise a 401 is sent.