Documentation
¶
Index ¶
Constants ¶
const ( // HeaderUserID is the HTTP header where the user ID is stored. HeaderUserID = "X-ID" // HeaderTenantID is the HTTP header where the tenant ID is stored. HeaderTenantID = "X-Tenant-ID" )
Variables ¶
This section is empty.
Functions ¶
func Log ¶
func Log(next echo.HandlerFunc) echo.HandlerFunc
Log is the echo middleware that logs one line per request, with the user and tenant taken from the headers named above and the request URI's query passed through RedactQuery. It measures with the wall clock deliberately: this is elapsed time, not a timestamp a test needs to control.
It runs the error handler itself rather than returning the error, so the status that handler writes is already on the response by the time the line is built, and it unwraps echo's [http.ResponseWriter] to read that status and the byte count back out.
func NewSlogLogger ¶ added in v0.27.0
NewSlogLogger returns the logger Echo writes its internals to, backed by logrus so the framework's own messages land in the same stream and format as everything else ShellHub logs.
func RedactQuery ¶ added in v0.27.0
RedactQuery returns rawQuery with "REDACTED" as the value of every parameter that carries a credential or personal data to a route: token, invite, approval_code and email. Names are compared after percent-decoding and case-insensitively, as echo's binder also binds a name sent in another case. Everything else keeps its original form and order. A query that cannot be parsed comes back as "REDACTED" whole. The list is matched by name, so a route that starts reading a secret from a new parameter leaks it until the parameter is added.
Types ¶
This section is empty.