diff --git a/cmd/server/api/http.go b/cmd/server/api/http.go index 6f7ad09..d02daaf 100644 --- a/cmd/server/api/http.go +++ b/cmd/server/api/http.go @@ -26,7 +26,7 @@ type httpServer struct { clients *clients.Manager } -func NewHttpServer(ctx context.Context, jwk *ioconnect.JWK, clientMgr *clients.Manager) *httpServer { +func Run(ctx context.Context, jwk *ioconnect.JWK, clientMgr *clients.Manager, address string) error { s := &httpServer{ ctx: ctx, engine: gin.Default(), @@ -34,28 +34,13 @@ func NewHttpServer(ctx context.Context, jwk *ioconnect.JWK, clientMgr *clients.M clients: clientMgr, } - slog.Debug("jwk information", - "did:io", jwk.DID(), - "did:io#key", jwk.KID(), - "ka did:io", jwk.KeyAgreementDID(), - "ka did:io#key", jwk.KeyAgreementKID(), - "doc", jwk.Doc(), - ) - s.engine.POST("/issue_vc", s.issueJWTCredential) s.engine.POST("/device/data", s.verifyToken, s.receiveDeviceData) s.engine.GET("/device/query", s.verifyToken, s.queryDeviceState) s.engine.GET("/didDoc", s.didDoc) - return s -} - -// this func will block caller -func (s *httpServer) Run(address string) error { - if err := s.engine.Run(address); err != nil { - return errors.Wrap(err, "failed to start http server") - } - return nil + err := s.engine.Run(address) + return errors.Wrap(err, "failed to start http server") } // verifyToken make sure the client token is issued by sequencer diff --git a/cmd/server/main.go b/cmd/server/main.go index 1511ad0..def68a5 100644 --- a/cmd/server/main.go +++ b/cmd/server/main.go @@ -137,7 +137,7 @@ func runHTTP(ctx context.Context) { panic(errors.Wrap(err, "failed to new clients manager")) } go func() { - if err := api.NewHttpServer(ctx, jwk, clientMgr).Run(":9000"); err != nil { + if err := api.Run(ctx, jwk, clientMgr, ":9000"); err != nil { panic(err) } }()