Function-valued header rewrite: Rule.SetFunc #40
Labels
No labels
bug
dependencies
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
mikluko/multiproxy#40
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
headers.Rule.Setis a fixedhttp.Header, built once when the middleware is constructed. That fits a static API key and nothing that changes per request or over time:/repos/{owner}/...)Proposal: a function-valued counterpart to
Set.Points worth settling:
SetFuncerrors, the request must not go upstream without the header the rule was meant to set. Forwarding it bare would send an unauthenticated request at best, and the client's own header at worst ifDeletedid not strip it. 502 plus a log record via thelogmiddleware helpers.rq.Context()carries cancellation and the trace span, so a slow fetch stops when the client goes away.SetFuncreceives the request to decide by method, path or other headers; it returns headers instead of mutatingrq, so ordering within the middleware stays defined byRewrite.SetFuncper matching request; a function wrapping a remote fetch keeps its own cache.Example:
The CLI flags stay static; this is a library addition only.