Skip to content

Commit

Permalink
refactor: improve internal server endpoints URL structure
Browse files Browse the repository at this point in the history
  • Loading branch information
sietseringers committed Oct 9, 2019
1 parent 7276abc commit 192636d
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions internal/servercore/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ func (s *Server) StartSession(req interface{}) (*irma.Qr, string, error) {
}
return &irma.Qr{
Type: action,
URL: s.conf.URL + session.clientToken,
URL: s.conf.URL + "session/" + session.clientToken,
}, session.token, nil
}

Expand Down Expand Up @@ -238,7 +238,7 @@ func (s *Server) CancelSession(token string) error {
}

func ParsePath(path string) (string, string, error) {
pattern := regexp.MustCompile("(\\w+)/?(|commitments|proofs|status|statusevents)$")
pattern := regexp.MustCompile("session/(\\w+)/?(|commitments|proofs|status|statusevents)$")
matches := pattern.FindStringSubmatch(path)
if len(matches) != 3 {
return "", "", server.LogWarning(errors.Errorf("Invalid URL: %s", path))
Expand Down
2 changes: 1 addition & 1 deletion internal/sessiontest/session_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ func TestStaticQRSession(t *testing.T) {
// setup static QR and other variables
qr := &irma.Qr{
Type: irma.ActionRedirect,
URL: "http://localhost:48682/irma/-/static/staticsession",
URL: "http://localhost:48682/irma/session/staticsession",
}
bts, err := json.Marshal(qr)
require.NoError(t, err)
Expand Down
4 changes: 2 additions & 2 deletions irma/cmd/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ irma session --server http://localhost:48680 --authmethod token --key mytoken --
if err != nil {
die("", err)
}

// Make sure we always run with latest configuration
irmaconfig.UpdateSchemes()

Expand Down Expand Up @@ -231,7 +231,7 @@ func init() {
if err != nil {
logger.Warn("Could not determine local IP address: ", err.Error())
} else {
defaulturl = "http://" + defaulturl + ":port"
defaulturl = "http://" + defaulturl + ":port/session"
}

flags := sessionCmd.Flags()
Expand Down
2 changes: 1 addition & 1 deletion server/requestorserver/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ func (s *Server) attachClientEndpoints(router *chi.Mux) {
if s.conf.Verbose >= 2 {
r.Use(s.logHandler("staticsession", true, true, true))
}
r.Post("/irma/-/static/{name}", s.handleCreateStatic)
r.Post("/irma/session/{name}", s.handleCreateStatic)
})
}

Expand Down

0 comments on commit 192636d

Please sign in to comment.