Skip to content
This repository has been archived by the owner on Dec 12, 2024. It is now read-only.

Commit

Permalink
Moarrr docs (#363)
Browse files Browse the repository at this point in the history
* Added health docs

* Added readiness check.

* Some docs.

* Update credential.go
  • Loading branch information
andresuribe87 authored Mar 30, 2023
1 parent 96b0946 commit ffc618f
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 9 deletions.
9 changes: 7 additions & 2 deletions pkg/server/router/credential.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,12 @@ func (c CreateCredentialRequest) ToServiceRequest() credential.CreateCredentialR
}

type CreateCredentialResponse struct {
Credential *credsdk.VerifiableCredential `json:"credential,omitempty"`
CredentialJWT *keyaccess.JWT `json:"credentialJwt,omitempty"`
// A verifiable credential conformant to the media type `application/vc+ld+json`.
Credential *credsdk.VerifiableCredential `json:"credential,omitempty"`

// The same verifiable credential, but using the syntax defined for the media type `application/vc+jwt`. See
// https://w3c.github.io/vc-jwt/ for more details.
CredentialJWT *keyaccess.JWT `json:"credentialJwt,omitempty"`
}

// CreateCredential godoc
Expand Down Expand Up @@ -392,6 +396,7 @@ func (cr CredentialRouter) VerifyCredential(ctx context.Context, w http.Response
}

type GetCredentialsResponse struct {
// Array of credential containers.
Credentials []credmodel.Container `json:"credentials"`
}

Expand Down
1 change: 1 addition & 0 deletions pkg/server/router/health.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
)

type GetHealthCheckResponse struct {
// Status is always equal to `OK`.
Status string `json:"status"`
}

Expand Down
13 changes: 8 additions & 5 deletions pkg/server/router/readiness.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,22 @@ type readiness struct {
}

type GetReadinessResponse struct {
Status svcframework.Status `json:"status"`
// Overall status of the ssi service.
Status svcframework.Status `json:"status"`

// A map from the name of the service ot the status of that current service.
ServiceStatuses map[svcframework.Type]svcframework.Status `json:"serviceStatuses"`
}

// Readiness godoc
//
// @Summary Readiness
// @Description ready runs a number of application specific checks to see if all the
// @Description relied upon service are healthy. Should return a 500 if not ready.
// @Description Readiness runs a number of application specific checks to see if all the relied upon services are
// @Description healthy.
// @Tags Readiness
// @Accept json
// @Produce json
// @Success 200 {string} string "OK"
// @Success 200 {object} GetReadinessResponse
// @Router /readiness [get]
func (r readiness) ready(ctx context.Context, w http.ResponseWriter, _ *http.Request) error {
services := r.getter.getServices()
Expand All @@ -56,7 +59,7 @@ func (r readiness) ready(ctx context.Context, w http.ResponseWriter, _ *http.Req
} else {
status = svcframework.Status{
Status: svcframework.StatusReady,
Message: "all service ready",
Message: "all services ready",
}
}
response := GetReadinessResponse{
Expand Down
7 changes: 5 additions & 2 deletions pkg/service/framework/framework.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,11 @@ func (t Type) String() string {

// Status is for service reporting on their status
type Status struct {
Status StatusState `json:"status,omitempty"`
Message string `json:"message,omitempty"`
// Either `ready` or `not_ready`.
Status StatusState `json:"status,omitempty"`

// When `status` is `not_ready`, then message contains explanation of why it's not ready.
Message string `json:"message,omitempty"`
}

func (s Status) IsReady() bool {
Expand Down

0 comments on commit ffc618f

Please sign in to comment.