implemented CLI interface
This commit is contained in:
@@ -17,7 +17,7 @@ import (
|
||||
)
|
||||
|
||||
// initHttp setup and start the http server. Blocking
|
||||
func initHttp(resolveContext context.Context, schema graphql.Schema) error {
|
||||
func initHttp(resolveContext context.Context, schema graphql.Schema, address string) error {
|
||||
h := handler.New(&handler.Config{
|
||||
Schema: &schema,
|
||||
Pretty: true,
|
||||
@@ -53,7 +53,7 @@ func initHttp(resolveContext context.Context, schema graphql.Schema) error {
|
||||
// Init the embedded static files
|
||||
initStatic()
|
||||
|
||||
return http.ListenAndServe(":8080", nil)
|
||||
return http.ListenAndServe(address, nil)
|
||||
}
|
||||
|
||||
func httpGetFile(ctx context.Context, rw http.ResponseWriter, r *http.Request) {
|
||||
|
||||
@@ -19,6 +19,8 @@ type AppConfig struct {
|
||||
S3Buket string
|
||||
CacheTTL time.Duration
|
||||
CacheCleanup time.Duration
|
||||
Address string
|
||||
LogDebug bool
|
||||
}
|
||||
|
||||
// File represents a file with its metadata
|
||||
@@ -68,7 +70,9 @@ func setupS3Client(config AppConfig) (*minio.Client, error) {
|
||||
// Start starts the app
|
||||
func Start(config AppConfig) {
|
||||
|
||||
log.SetLevel(log.DebugLevel)
|
||||
if config.LogDebug {
|
||||
log.SetLevel(log.DebugLevel)
|
||||
}
|
||||
|
||||
log.Info("Starting")
|
||||
log.Debug("Setting up s3 client")
|
||||
@@ -96,7 +100,7 @@ func Start(config AppConfig) {
|
||||
resolveContext = context.WithValue(resolveContext, "loader", loaderMap)
|
||||
|
||||
log.Debug("Starting HTTP server")
|
||||
err = initHttp(resolveContext, schema)
|
||||
err = initHttp(resolveContext, schema, config.Address)
|
||||
|
||||
if err != nil {
|
||||
log.Error("Failed to start webserver: ", err.Error())
|
||||
|
||||
Reference in New Issue
Block a user