Skip to content

Commit

Permalink
Added request URL and method to context
Browse files Browse the repository at this point in the history
  • Loading branch information
kristinapathak committed Apr 15, 2019
1 parent a1306ac commit 51e51e6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
4 changes: 4 additions & 0 deletions bascule/basculehttp/constructor.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ func (c *constructor) decorate(next http.Handler) http.Handler {
bascule.Authentication{
Authorization: key,
Token: token,
Request: bascule.Request{
URL: request.URL.EscapedPath(),
Method: request.Method,
},
},
)
logger.Log(level.Key(), level.DebugValue(), "msg", "authentication added to context",
Expand Down
10 changes: 9 additions & 1 deletion bascule/context.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package bascule

import "context"
import (
"context"
)

// Authorization represents the authorization mechanism performed on the token,
// e.g. "Basic", "Bearer", etc for HTTP security environments.
Expand All @@ -10,6 +12,12 @@ type Authorization string
type Authentication struct {
Authorization Authorization
Token Token
Request Request
}

type Request struct {
URL string
Method string
}

type authenticationKey struct{}
Expand Down

0 comments on commit 51e51e6

Please sign in to comment.