basicly implement acl crud ops with roles and resources
This commit is contained in:
20
internal/server/error.go
Normal file
20
internal/server/error.go
Normal file
@@ -0,0 +1,20 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type ErrorResponse struct {
|
||||
Error string `json:"error"`
|
||||
Details string `json:"details,omitempty"`
|
||||
}
|
||||
|
||||
func WriteError(w http.ResponseWriter, error, details string, statusCode int) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(statusCode)
|
||||
json.NewEncoder(w).Encode(ErrorResponse{
|
||||
Error: error,
|
||||
Details: details,
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user