Move log code out of auto-generated files (#791)
* Move log coude out of auto-generated files Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com> * Configure API Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
This commit is contained in:
@@ -21,6 +21,7 @@ import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
xcerts "github.com/minio/pkg/certs"
|
||||
@@ -102,6 +103,7 @@ func buildServer() (*restapi.Server, error) {
|
||||
}
|
||||
|
||||
api := operations.NewConsoleAPI(swaggerSpec)
|
||||
api.Logger = restapi.LogInfo
|
||||
server := restapi.NewServer(api)
|
||||
|
||||
parser := flags.NewParser(server, flags.Default)
|
||||
@@ -110,6 +112,9 @@ func buildServer() (*restapi.Server, error) {
|
||||
|
||||
server.ConfigureFlags()
|
||||
|
||||
// register all APIs
|
||||
server.ConfigureAPI()
|
||||
|
||||
for _, optsGroup := range api.CommandLineOptionsGroups {
|
||||
_, err := parser.AddGroup(optsGroup.ShortDescription, optsGroup.LongDescription, optsGroup.Options)
|
||||
if err != nil {
|
||||
@@ -190,8 +195,23 @@ func StartServer(ctx *cli.Context) error {
|
||||
return err
|
||||
}
|
||||
|
||||
s := server.Configure(rctx)
|
||||
defer s.Shutdown()
|
||||
server.Host = rctx.Host
|
||||
server.Port = rctx.HTTPPort
|
||||
restapi.Port = strconv.Itoa(server.Port)
|
||||
restapi.Hostname = server.Host
|
||||
|
||||
if len(restapi.GlobalPublicCerts) > 0 {
|
||||
// If TLS certificates are provided enforce the HTTPS schema, meaning console will redirect
|
||||
// plain HTTP connections to HTTPS server
|
||||
server.EnabledListeners = []string{"http", "https"}
|
||||
server.TLSPort = rctx.HTTPSPort
|
||||
// Need to store tls-port, tls-host un config variables so secure.middleware can read from there
|
||||
restapi.TLSPort = strconv.Itoa(server.TLSPort)
|
||||
restapi.Hostname = rctx.Host
|
||||
restapi.TLSRedirect = rctx.TLSRedirect
|
||||
}
|
||||
|
||||
defer server.Shutdown()
|
||||
|
||||
// subnet license refresh process
|
||||
go func() {
|
||||
@@ -218,5 +238,5 @@ func StartServer(ctx *cli.Context) error {
|
||||
}
|
||||
}()
|
||||
|
||||
return s.Serve()
|
||||
return server.Serve()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user