Documentation
¶
Overview ¶
Package ephttp is the HTTP surface of endpoints (#2174): every request to /endpoints/{name}/... and the bot check a public one is answered behind (/botcheck/challenge and /botcheck/solver.js).
A signed_in endpoint answers a browser session or an API key, and the identity the platform found is what the handler reads as req.caller; it never comes from the request body. A public endpoint answers a request carrying an accepted bot check answer in the X-Bot-Check header, or a GET or HEAD with none where the binding opens its reads.
These routes answer their own cross-origin requests from each binding's allowed origins; the platform's CORS layer leaves them alone. No limit here depends on the client's address, which a request behind an ingress and a load balancer does not carry.
Index ¶
Constants ¶
const ( // PathPrefix is every endpoint's prefix; a request's path is // /endpoints/{name} and what follows it. PathPrefix = "/endpoints/" // BotCheckPrefix is the bot check's routes. BotCheckPrefix = "/botcheck/" )
The routes.
const HeaderBotCheck = "X-Bot-Check"
HeaderBotCheck carries a public request's bot check answer.
Variables ¶
var ErrForbidden = errors.New("the request's credential was refused")
ErrForbidden is what Authenticate returns for a credential that was presented and refused for a reason other than its absence (a browser session without its CSRF token), which is answered 403 rather than 401.
Functions ¶
This section is empty.
Types ¶
type Checker ¶
type Checker interface {
PublicAllowed(ctx context.Context) (bool, error)
Issue(ctx context.Context, endpoint string) (botcheck.Challenge, error)
Verify(ctx context.Context, endpoint, answer string) error
}
Checker is the deployment's bot check.
type Handler ¶
type Handler struct {
Runner Runner
Checker Checker
// Authenticate is who sent the request: a browser session or an API key.
// Nil caller and nil error is nobody.
Authenticate func(r *http.Request) (*eprun.Caller, error)
// contains filtered or unexported fields
}
Handler answers the routes.