feat: Added basic user authorization
This commit is contained in:
@@ -1,8 +1,11 @@
|
||||
package http
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"git.ostiwe.com/ostiwe-com/status/model"
|
||||
)
|
||||
|
||||
func ExtractLimitOffset(r *http.Request) (int, int, ResponseErrReadyToSend) {
|
||||
@@ -44,3 +47,18 @@ func ExtractLimitOffset(r *http.Request) (int, int, ResponseErrReadyToSend) {
|
||||
|
||||
return limitInt, offsetInt, nil
|
||||
}
|
||||
|
||||
func GetUser(ctx context.Context) *model.User {
|
||||
ctxValue := ctx.Value("user")
|
||||
|
||||
if ctxValue == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
user, ok := ctxValue.(*model.User)
|
||||
if !ok {
|
||||
return nil
|
||||
}
|
||||
|
||||
return user
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user