forked from TrueCloudLab/frostfs-rest-gw
[#1] Add basic structure and operations
Signed-off-by: Denis Kirillov <denis@nspcc.ru>
This commit is contained in:
parent
eb642eae89
commit
9f752cd756
65 changed files with 11534 additions and 0 deletions
42
cmd/neofs-rest-gw/main.go
Normal file
42
cmd/neofs-rest-gw/main.go
Normal file
|
@ -0,0 +1,42 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/go-openapi/loads"
|
||||
"github.com/nspcc-dev/neofs-rest-gw/gen/restapi"
|
||||
"github.com/nspcc-dev/neofs-rest-gw/gen/restapi/operations"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
func main() {
|
||||
ctx := context.Background()
|
||||
|
||||
v := config()
|
||||
logger := newLogger(v)
|
||||
|
||||
neofsAPI, err := newNeofsAPI(ctx, logger, v)
|
||||
if err != nil {
|
||||
logger.Fatal("init neofs", zap.Error(err))
|
||||
}
|
||||
|
||||
swaggerSpec, err := loads.Analyzed(restapi.SwaggerJSON, "")
|
||||
if err != nil {
|
||||
logger.Fatal("init spec", zap.Error(err))
|
||||
}
|
||||
|
||||
api := operations.NewNeofsRestGwAPI(swaggerSpec)
|
||||
server := restapi.NewServer(api, serverConfig(v))
|
||||
defer func() {
|
||||
if err = server.Shutdown(); err != nil {
|
||||
logger.Error("shutdown", zap.Error(err))
|
||||
}
|
||||
}()
|
||||
|
||||
server.ConfigureAPI(neofsAPI.Configure)
|
||||
|
||||
// serve API
|
||||
if err = server.Serve(); err != nil {
|
||||
logger.Fatal("serve", zap.Error(err))
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue