init
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
package handlers
|
||||
|
||||
import (
|
||||
"authorization/helper"
|
||||
"authorization/models"
|
||||
"authorization/services"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func AuthorizeHandler(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
var request models.AuthorizationRequest
|
||||
|
||||
err := json.NewDecoder(r.Body).Decode(&request)
|
||||
if err != nil {
|
||||
helper.RespondWithError(w, http.StatusBadRequest, "Invalid request payload")
|
||||
return
|
||||
}
|
||||
|
||||
allowed := services.Authorize()
|
||||
if !allowed {
|
||||
helper.RespondWithError(w, http.StatusForbidden, "Access denied")
|
||||
return
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user