Skip to content

Commit

Permalink
Fixed routing for one usecase
Browse files Browse the repository at this point in the history
  • Loading branch information
kompotkot committed Dec 14, 2023
1 parent 5c56518 commit e212591
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions server.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,22 +244,22 @@ func (server *Server) signersHandler(w http.ResponseWriter, r *http.Request) {
server.signersRoute(w, r)
return
case http.MethodPost:
var signer string
routePathSlice := strings.Split(r.URL.Path, "/")
requestedSigner := common.HexToAddress(routePathSlice[2])
for s := range server.AvailableSigners {
if s == requestedSigner.String() {
signer = s
break
}
requestedSigner := common.HexToAddress(routePathSlice[2]).String()
_, ok := server.AvailableSigners[requestedSigner]
if !ok {
http.Error(w, fmt.Sprintf("Unacceptable signer provided %s", requestedSigner), http.StatusBadRequest)
return
}
if signer == "" {
http.Error(w, fmt.Sprintf("Unacceptable signer provided %s", signer), http.StatusBadRequest)
switch {
case strings.Contains(r.URL.Path, "/dropper/sign"):
// TODO: (kompotkot): Re-write in subroutes and subapps when times come
server.signDropperRoute(w, r, requestedSigner)
return
default:
http.Error(w, "Not found", http.StatusNotFound)
return
}

server.signDropperRoute(w, r, signer)
return
default:
http.Error(w, "Method not allowed", http.StatusMethodNotAllowed)
return
Expand All @@ -281,7 +281,6 @@ func (server *Server) signersRoute(w http.ResponseWriter, r *http.Request) {

// signDropperRoute sign dropper call requests
func (server *Server) signDropperRoute(w http.ResponseWriter, r *http.Request, signer string) {

authorizationContext := r.Context().Value("authorizationContext").(AuthorizationContext)
authorizationToken := authorizationContext.AuthorizationToken

Expand Down

0 comments on commit e212591

Please sign in to comment.