mirror of
https://github.com/muety/wakapi.git
synced 2023-08-10 21:12:56 +03:00
fix: sentry middleware interface conversion
This commit is contained in:
parent
c1f1b05fa8
commit
cf5a515952
@ -146,15 +146,12 @@ func initSentry(config sentryConfig, debug bool) {
|
|||||||
|
|
||||||
// returns a user id
|
// returns a user id
|
||||||
func getPrincipal(r *http.Request) string {
|
func getPrincipal(r *http.Request) string {
|
||||||
type identifiable interface {
|
type principalIdentityGetter interface {
|
||||||
Identity() string
|
GetPrincipalIdentity() string
|
||||||
}
|
|
||||||
type principalGetter interface {
|
|
||||||
GetPrincipal() *identifiable
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if p := r.Context().Value("principal"); p != nil {
|
if p := r.Context().Value("principal"); p != nil {
|
||||||
return (*p.(principalGetter).GetPrincipal()).Identity()
|
return p.(principalIdentityGetter).GetPrincipalIdentity()
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -20,6 +20,10 @@ func (c *PrincipalContainer) GetPrincipal() *models.User {
|
|||||||
return c.principal
|
return c.principal
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *PrincipalContainer) GetPrincipalIdentity() string {
|
||||||
|
return c.principal.Identity()
|
||||||
|
}
|
||||||
|
|
||||||
// This middleware is a bit of a dirty workaround to the fact that a http.Request's context
|
// This middleware is a bit of a dirty workaround to the fact that a http.Request's context
|
||||||
// does not allow to pass values from an inner to an outer middleware. Calling WithContext() on a
|
// does not allow to pass values from an inner to an outer middleware. Calling WithContext() on a
|
||||||
// request shallow-copies the whole request itself and therefore, in a chain of handler1(handler2()),
|
// request shallow-copies the whole request itself and therefore, in a chain of handler1(handler2()),
|
||||||
|
Loading…
Reference in New Issue
Block a user