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

DID API #17

Merged
merged 24 commits into from
Apr 3, 2022
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,7 @@ vendor/
.DS_Store

# IDE
.idea/
.idea/

# DB files
*.db
18 changes: 10 additions & 8 deletions service/main.go → cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,20 @@ import (
"context"
"expvar"
"fmt"
"github.com/tbd54566975/vc-service/pkg/server"
"log"
"net/http"
"os"
"os/signal"
"syscall"
"time"

"github.com/tbd54566975/vc-service/service/handlers"

"github.com/ardanlabs/conf"
"github.com/pkg/errors"
)

const (
ServiceName = "vc-service"
ServiceName = "vc-server"
LogPrefix = ServiceName + ": "
)

Expand All @@ -28,8 +27,7 @@ func main() {
svcLog.Println("Starting up")

if err := run(svcLog); err != nil {
svcLog.Println("main: error:", err)
os.Exit(1)
svcLog.Fatalf("main: error:", err)
}
}

Expand Down Expand Up @@ -91,17 +89,21 @@ func run(log *log.Logger) error {
shutdown := make(chan os.Signal, 1)
signal.Notify(shutdown, os.Interrupt, syscall.SIGTERM)

vcs, err := server.NewHTTPServer(shutdown, log)
if err != nil {
log.Fatalf("could not start http services: %", err.Error())
}
api := http.Server{
Addr: cfg.Web.APIHost,
Handler: handlers.API(shutdown, log),
Handler: vcs,
ReadTimeout: cfg.Web.ReadTimeout,
WriteTimeout: cfg.Web.WriteTimeout,
}

serverErrors := make(chan error, 1)

go func() {
log.Printf("main: API server started and listening on -> %s", api.Addr)
log.Printf("main: server started and listening on -> %s", api.Addr)

serverErrors <- api.ListenAndServe()
}()
Expand All @@ -110,7 +112,7 @@ func run(log *log.Logger) error {
case err := <-serverErrors:
return errors.Wrap(err, "server error")
case sig := <-shutdown:
log.Printf("main: Shutdown signal received -> %v", sig)
log.Printf("main: shutdown signal received -> %v", sig)

ctx, cancel := context.WithTimeout(context.Background(), cfg.Web.ShutdownTimeout)
defer cancel()
Expand Down
48 changes: 43 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,18 +1,56 @@
module github.com/tbd54566975/vc-service

go 1.16
go 1.17

require (
github.com/TBD54566975/did-sdk v0.0.0-20220330042841-cde17eb1a120
github.com/ardanlabs/conf v1.4.0
github.com/boltdb/bolt v1.3.1
github.com/dimfeld/httptreemux/v5 v5.4.0
github.com/go-playground/locales v0.14.0
github.com/go-playground/universal-translator v0.18.0
github.com/google/uuid v1.3.0
github.com/leodido/go-urn v1.2.1 // indirect
github.com/magefile/mage v1.12.1
github.com/magefile/mage v1.13.0
github.com/mr-tron/base58 v1.1.3
github.com/pkg/errors v0.9.1
github.com/stretchr/testify v1.7.0
go.opentelemetry.io/otel/trace v1.3.0
golang.org/x/crypto v0.0.0-20220315160706-3147a52a75dd
gopkg.in/go-playground/assert.v1 v1.2.1 // indirect
golang.org/x/crypto v0.0.0-20220331220935-ae2d96664a29
gopkg.in/go-playground/validator.v9 v9.31.0
)

require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 // indirect
github.com/go-playground/validator/v10 v10.10.0 // indirect
github.com/gobuffalo/logger v1.0.6 // indirect
github.com/gobuffalo/packd v1.0.1 // indirect
github.com/gobuffalo/packr/v2 v2.8.3 // indirect
github.com/goccy/go-json v0.9.4 // indirect
github.com/karrick/godirwalk v1.16.1 // indirect
github.com/leodido/go-urn v1.2.1 // indirect
github.com/lestrrat-go/backoff/v2 v2.0.8 // indirect
github.com/lestrrat-go/blackmagic v1.0.0 // indirect
github.com/lestrrat-go/httpcc v1.0.0 // indirect
github.com/lestrrat-go/iter v1.0.1 // indirect
github.com/lestrrat-go/jwx v1.2.19 // indirect
github.com/lestrrat-go/option v1.0.0 // indirect
github.com/markbates/errx v1.1.0 // indirect
github.com/markbates/oncer v1.0.0 // indirect
github.com/markbates/safe v1.0.1 // indirect
github.com/multiformats/go-base32 v0.0.3 // indirect
github.com/multiformats/go-base36 v0.1.0 // indirect
github.com/multiformats/go-multibase v0.0.3 // indirect
github.com/multiformats/go-multicodec v0.4.0 // indirect
github.com/multiformats/go-varint v0.0.6 // indirect
github.com/piprate/json-gold v0.4.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/pquerna/cachecontrol v0.0.0-20180517163645-1555304b9b35 // indirect
github.com/sirupsen/logrus v1.8.1 // indirect
go.opentelemetry.io/otel v1.3.0 // indirect
golang.org/x/sys v0.0.0-20220330033206-e17cdc41300f // indirect
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect
golang.org/x/text v0.3.6 // indirect
gopkg.in/go-playground/assert.v1 v1.2.1 // indirect
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
)
Loading