Files
api-gateway/app/res/error.go
Björn Benouarets 31f5b4081a init: Initial commit
2026-02-05 18:37:35 +01:00

22 lines
503 B
Go

package res
import (
"encoding/json"
"net/http"
)
type ErrorResponse struct {
Message string `json:"message"`
Code int `json:"code"`
}
func Unauthorized(w http.ResponseWriter) {
w.WriteHeader(http.StatusUnauthorized)
json.NewEncoder(w).Encode(ErrorResponse{Message: "Unauthorized", Code: http.StatusUnauthorized})
}
func Forbidden(w http.ResponseWriter) {
w.WriteHeader(http.StatusForbidden)
json.NewEncoder(w).Encode(ErrorResponse{Message: "Forbidden", Code: http.StatusForbidden})
}