feat: Added basic user authorization
This commit is contained in:
@@ -110,6 +110,7 @@ func (r responseErrBuilder) Send(response http.ResponseWriter, request *http.Req
|
||||
r.status = http.StatusInternalServerError
|
||||
}
|
||||
|
||||
response.Header().Set("Content-Type", "application/json")
|
||||
response.WriteHeader(r.status)
|
||||
|
||||
_, err = response.Write(format)
|
||||
|
||||
@@ -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