working sub

This commit is contained in:
2026-03-05 12:21:32 +03:00
parent 205d9cf8b0
commit 951f3ab482
6 changed files with 65 additions and 14 deletions

View File

@@ -12,6 +12,7 @@ type Error struct {
}
func WriteError(w http.ResponseWriter, err error) {
log.Println(err)
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusBadRequest)
e := json.NewEncoder(w).Encode(Error{
@@ -59,6 +60,7 @@ func ReadBody[T any](r *http.Request) (T, error) {
}
func CheckToken(r *http.Request) bool {
auth := r.Header.Get("Authorization")
log.Println(auth)
if auth != cfg.JWTSecret {
return false
}