Skip to content

Commit

Permalink
PR(FIX): Panic the acp handler internal errors
Browse files Browse the repository at this point in the history
  • Loading branch information
shahzadlone committed Oct 17, 2024
1 parent c549570 commit 8c2f028
Showing 1 changed file with 3 additions and 15 deletions.
18 changes: 3 additions & 15 deletions http/handler_acp.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,7 @@ import (
type acpHandler struct{}

func (s *acpHandler) AddPolicy(rw http.ResponseWriter, req *http.Request) {
db, ok := req.Context().Value(dbContextKey).(client.DB)
if !ok {
responseJSON(rw, http.StatusBadRequest, errorResponse{NewErrFailedToGetContext("db")})
return
}
db := req.Context().Value(dbContextKey).(client.DB)

policyBytes, err := io.ReadAll(req.Body)
if err != nil {
Expand All @@ -47,11 +43,7 @@ func (s *acpHandler) AddPolicy(rw http.ResponseWriter, req *http.Request) {
}

func (s *acpHandler) AddDocActorRelationship(rw http.ResponseWriter, req *http.Request) {
db, ok := req.Context().Value(dbContextKey).(client.DB)
if !ok {
responseJSON(rw, http.StatusBadRequest, errorResponse{NewErrFailedToGetContext("db")})
return
}
db := req.Context().Value(dbContextKey).(client.DB)

var message addDocActorRelationshipRequest
err := requestJSON(req, &message)
Expand All @@ -76,11 +68,7 @@ func (s *acpHandler) AddDocActorRelationship(rw http.ResponseWriter, req *http.R
}

func (s *acpHandler) DeleteDocActorRelationship(rw http.ResponseWriter, req *http.Request) {
db, ok := req.Context().Value(dbContextKey).(client.DB)
if !ok {
responseJSON(rw, http.StatusBadRequest, errorResponse{NewErrFailedToGetContext("db")})
return
}
db := req.Context().Value(dbContextKey).(client.DB)

var message deleteDocActorRelationshipRequest
err := requestJSON(req, &message)
Expand Down

0 comments on commit 8c2f028

Please sign in to comment.