init: Initial commit
This commit is contained in:
21
app/res/error.go
Normal file
21
app/res/error.go
Normal file
@@ -0,0 +1,21 @@
|
||||
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})
|
||||
}
|
||||
Reference in New Issue
Block a user