Skip to content

Commit

Permalink
Status 2 (#668)
Browse files Browse the repository at this point in the history
* tmp

* fix tests

* fix int test

* fix config
  • Loading branch information
decentralgabe authored Aug 23, 2023
1 parent c469402 commit a094242
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 16 deletions.
8 changes: 1 addition & 7 deletions integration/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,15 @@ import (
"github.com/pkg/errors"
"github.com/sirupsen/logrus"

"github.com/tbd54566975/ssi-service/config"
credmodel "github.com/tbd54566975/ssi-service/internal/credential"
"github.com/tbd54566975/ssi-service/internal/keyaccess"
"github.com/tbd54566975/ssi-service/internal/util"
"github.com/tbd54566975/ssi-service/pkg/server/router"
"github.com/tbd54566975/ssi-service/pkg/service/framework"
)

const (
// Note: for local testing change this to port 3000
endpoint = "http://localhost:8080/"
endpoint = "http://localhost:3000/"
version = "v1/"
MaxElapsedTime = 120 * time.Second
)
Expand All @@ -47,10 +45,6 @@ func init() {
DisableQuote: true,
ForceColors: true,
})

config.SetAPIBase(endpoint)
config.SetServicePath(framework.Credential, "/credentials")
config.SetServicePath(framework.Schema, "/schemas")
}

type didConfigurationResourceParams struct {
Expand Down
18 changes: 9 additions & 9 deletions pkg/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,6 @@ func NewSSIServer(shutdown chan os.Signal, cfg config.SSIServiceConfig) (*SSISer
// make sure to set the api base in our service info
config.SetAPIBase(cfg.Services.ServiceEndpoint)

// allows for a custom URI to be used for status list credentials, if not set, we use the default path
if cfg.Services.StatusEndpoint != "" {
config.SetStatusBase(cfg.Services.StatusEndpoint)
} else {
config.SetStatusBase(fmt.Sprintf("%s/status", config.GetServicePath(svcframework.Credential)))
}

// service-level routers
engine.GET(HealthPrefix, router.Health)
engine.GET(ReadinessPrefix, router.Readiness(ssi.GetServices()))
Expand All @@ -93,7 +86,7 @@ func NewSSIServer(shutdown chan os.Signal, cfg config.SSIServiceConfig) (*SSISer
if err = SchemaAPI(v1, ssi.Schema, ssi.Webhook); err != nil {
return nil, sdkutil.LoggingErrorMsg(err, "unable to instantiate Schema API")
}
if err = CredentialAPI(v1, ssi.Credential, ssi.Webhook); err != nil {
if err = CredentialAPI(v1, ssi.Credential, ssi.Webhook, cfg.Services.StatusEndpoint); err != nil {
return nil, sdkutil.LoggingErrorMsg(err, "unable to instantiate Credential API")
}
if err = OperationAPI(v1, ssi.Operation); err != nil {
Expand Down Expand Up @@ -207,7 +200,7 @@ func SchemaAPI(rg *gin.RouterGroup, service svcframework.Service, webhookService
}

// CredentialAPI registers all HTTP handlers for the Credentials Service
func CredentialAPI(rg *gin.RouterGroup, service svcframework.Service, webhookService *webhook.Service) (err error) {
func CredentialAPI(rg *gin.RouterGroup, service svcframework.Service, webhookService *webhook.Service, statusEndpoint string) (err error) {
credRouter, err := router.NewCredentialRouter(service)
if err != nil {
return sdkutil.LoggingErrorMsg(err, "creating credential router")
Expand All @@ -216,6 +209,13 @@ func CredentialAPI(rg *gin.RouterGroup, service svcframework.Service, webhookSer
// make sure the credential service is configured to use the correct path
config.SetServicePath(svcframework.Credential, CredentialsPrefix)

// allows for a custom URI to be used for status list credentials, if not set, we use the default path
if statusEndpoint != "" {
config.SetStatusBase(statusEndpoint)
} else {
config.SetStatusBase(fmt.Sprintf("%s/status", config.GetServicePath(svcframework.Credential)))
}

// Credentials
credentialAPI := rg.Group(CredentialsPrefix)
credentialAPI.PUT("", middleware.Webhook(webhookService, webhook.Credential, webhook.Create), credRouter.CreateCredential)
Expand Down

0 comments on commit a094242

Please sign in to comment.