16 lines
270 B
Go
16 lines
270 B
Go
package auth
|
|
|
|
import (
|
|
"errors"
|
|
"net/http"
|
|
)
|
|
|
|
func GetAuthInfo(r *http.Request) (*AuthInfo, error) {
|
|
ctxVal := r.Context().Value(AuthKey{})
|
|
if ctxVal == nil {
|
|
return nil, errors.New("can't get auth info")
|
|
}
|
|
authInfo := ctxVal.(*AuthInfo)
|
|
return authInfo, nil
|
|
}
|