feat: Added basic user authorization

This commit is contained in:
2025-08-20 01:24:49 +03:00
parent b72066f19e
commit fb4902dea6
15 changed files with 396 additions and 2 deletions

View File

@@ -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
}