Skip to content

Commit

Permalink
del get diddoc api (#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
huangzhiran authored Oct 31, 2024
1 parent 606fb46 commit 5172907
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 19 deletions.
21 changes: 3 additions & 18 deletions cmd/server/api/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,36 +26,21 @@ 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(),
jwk: jwk,
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
Expand Down
2 changes: 1 addition & 1 deletion cmd/server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}()
Expand Down

0 comments on commit 5172907

Please sign in to comment.