update module/import paths to new name, add cli framework

This commit is contained in:
Ben McClelland
2023-05-28 12:10:12 -07:00
parent 74b28283bf
commit 8b79fb24de
18 changed files with 216 additions and 41 deletions
+1 -1
View File
@@ -6,7 +6,7 @@ package controllers
import (
"github.com/aws/aws-sdk-go-v2/service/s3"
"github.com/aws/aws-sdk-go-v2/service/s3/types"
"github.com/versity/scoutgw/backend"
"github.com/versity/versitygw/backend"
"io"
"sync"
)
+3 -3
View File
@@ -13,9 +13,9 @@ import (
"github.com/aws/aws-sdk-go-v2/service/s3"
"github.com/aws/aws-sdk-go-v2/service/s3/types"
"github.com/gofiber/fiber/v2"
"github.com/versity/scoutgw/backend"
"github.com/versity/scoutgw/s3api/utils"
"github.com/versity/scoutgw/s3err"
"github.com/versity/versitygw/backend"
"github.com/versity/versitygw/s3api/utils"
"github.com/versity/versitygw/s3err"
)
type S3ApiController struct {
+2 -2
View File
@@ -10,8 +10,8 @@ import (
"github.com/aws/aws-sdk-go-v2/service/s3"
"github.com/gofiber/fiber/v2"
"github.com/valyala/fasthttp"
"github.com/versity/scoutgw/backend"
"github.com/versity/scoutgw/s3err"
"github.com/versity/versitygw/backend"
"github.com/versity/versitygw/s3err"
)
func TestNew(t *testing.T) {
+2 -2
View File
@@ -2,8 +2,8 @@ package s3api
import (
"github.com/gofiber/fiber/v2"
"github.com/versity/scoutgw/backend"
"github.com/versity/scoutgw/s3api/controllers"
"github.com/versity/versitygw/backend"
"github.com/versity/versitygw/s3api/controllers"
)
type S3ApiRouter struct{}
+1 -1
View File
@@ -4,7 +4,7 @@ import (
"testing"
"github.com/gofiber/fiber/v2"
"github.com/versity/scoutgw/backend"
"github.com/versity/versitygw/backend"
)
func TestS3ApiRouter_Init(t *testing.T) {
+28 -5
View File
@@ -1,9 +1,11 @@
package s3api
import (
"crypto/tls"
"github.com/gofiber/fiber/v2"
"github.com/gofiber/fiber/v2/middleware/logger"
"github.com/versity/scoutgw/backend"
"github.com/versity/versitygw/backend"
)
type S3ApiServer struct {
@@ -11,16 +13,37 @@ type S3ApiServer struct {
backend backend.Backend
router *S3ApiRouter
port string
cert *tls.Certificate
}
func New(app *fiber.App, be backend.Backend, port string) (s3ApiServer *S3ApiServer, err error) {
s3ApiServer = &S3ApiServer{app, be, new(S3ApiRouter), port}
func New(app *fiber.App, be backend.Backend, port string, opts ...Option) (*S3ApiServer, error) {
server := &S3ApiServer{
app: app,
backend: be,
router: new(S3ApiRouter),
port: port,
}
for _, opt := range opts {
opt(server)
}
app.Use(logger.New())
s3ApiServer.router.Init(app, be)
return
server.router.Init(app, be)
return server, nil
}
// Option sets various options for New()
type Option func(*S3ApiServer)
// WithTLS sets TLS Credentials
func WithTLS(cert tls.Certificate) Option {
return func(s *S3ApiServer) { s.cert = &cert }
}
func (sa *S3ApiServer) Serve() (err error) {
if sa.cert != nil {
return sa.app.ListenTLSWithCertificate(sa.port, *sa.cert)
}
return sa.app.Listen(sa.port)
}
+1 -1
View File
@@ -5,7 +5,7 @@ import (
"testing"
"github.com/gofiber/fiber/v2"
"github.com/versity/scoutgw/backend"
"github.com/versity/versitygw/backend"
)
func TestNew(t *testing.T) {