Module notifier_api

Shared helpers for the REST handlers: API-key auth, JSON body reading and JSON replies.

Description

Shared helpers for the REST handlers: API-key auth, JSON body reading and JSON replies.

Function Index

authorize/1When API_KEY is set, require Authorization: Bearer <key> (constant-time compare).
error_reply/4
read_json/1Read and decode a JSON request body (max 1 MiB).
reply/3

Function Details

authorize/1

authorize(Req::cowboy_req:req()) -> ok | {halt, cowboy_req:req()}

When API_KEY is set, require Authorization: Bearer <key> (constant-time compare). Replies 401 itself on failure.

error_reply/4

error_reply(Status::cowboy:http_status(), Code::atom(), Message::binary(), Req::cowboy_req:req()) -> cowboy_req:req()

read_json/1

read_json(Req0::cowboy_req:req()) -> {ok, term(), cowboy_req:req()} | {error, binary(), cowboy_req:req()}

Read and decode a JSON request body (max 1 MiB).

reply/3

reply(Status::cowboy:http_status(), Json::term(), Req::cowboy_req:req()) -> cowboy_req:req()


Generated by EDoc