Fix linter

This commit is contained in:
Nicolas JUHEL
2020-09-11 13:46:45 +02:00
parent 20f1085633
commit f7ef36d299
21 changed files with 379 additions and 339 deletions

View File

@@ -29,7 +29,7 @@ package httpserver
import "github.com/nabbar/golib/errors"
const (
EMPTY_PARAMS errors.CodeError = iota + errors.MIN_PKG_Httpserver
ErrorParamsEmpty errors.CodeError = iota + errors.MIN_PKG_Httpserver
)
var isCodeError = false
@@ -39,13 +39,15 @@ func IsCodeError() bool {
}
func init() {
isCodeError = errors.ExistInMapMessage(EMPTY_PARAMS)
errors.RegisterIdFctMessage(EMPTY_PARAMS, getMessage)
isCodeError = errors.ExistInMapMessage(ErrorParamsEmpty)
errors.RegisterIdFctMessage(ErrorParamsEmpty, getMessage)
}
func getMessage(code errors.CodeError) (message string) {
switch code {
case EMPTY_PARAMS:
case errors.UNK_ERROR:
return ""
case ErrorParamsEmpty:
return "given parameters is empty"
}

View File

@@ -40,11 +40,9 @@ import (
"syscall"
"time"
"golang.org/x/net/http2"
certif "github.com/nabbar/golib/certificates"
. "github.com/nabbar/golib/logger"
"github.com/nabbar/golib/logger"
"golang.org/x/net/http2"
)
const (
@@ -184,7 +182,7 @@ func (srv *modelServer) Listen() {
srv.srv = &http.Server{
Addr: srv.GetBindable(),
ErrorLog: GetLogger(ErrorLevel, log.LstdFlags|log.Lmicroseconds, "[http/http2 server '%s']", srv.GetBindable()),
ErrorLog: logger.GetLogger(logger.ErrorLevel, log.LstdFlags|log.Lmicroseconds, "[http/http2 server '%s']", srv.GetBindable()),
Handler: srv.hdl,
TLSConfig: srv.ssl,
}
@@ -201,23 +199,23 @@ func (srv *modelServer) Listen() {
}
err := http2.ConfigureServer(srv.srv, cnf)
FatalLevel.LogErrorCtxf(DebugLevel, "Configuring Server '%s'", err, srv.host)
logger.FatalLevel.LogErrorCtxf(logger.DebugLevel, "Configuring Server '%s'", err, srv.host)
go func() {
if srv.ssl == nil || !certif.CheckCertificates() {
InfoLevel.Logf("Server '%s' is starting with bindable: %s", srv.host, srv.GetBindable())
logger.InfoLevel.Logf("Server '%s' is starting with bindable: %s", srv.host, srv.GetBindable())
err := srv.srv.ListenAndServe()
FatalLevel.LogErrorCtxf(NilLevel, "Listen Server '%s'", err, srv.host)
logger.FatalLevel.LogErrorCtxf(logger.NilLevel, "Listen Server '%s'", err, srv.host)
} else {
InfoLevel.Logf("TLS Server '%s' is starting with bindable: %s", srv.host, srv.GetBindable())
logger.InfoLevel.Logf("TLS Server '%s' is starting with bindable: %s", srv.host, srv.GetBindable())
err := srv.srv.ListenAndServeTLS("", "")
FatalLevel.LogErrorCtxf(NilLevel, "Listen Server '%s'", err, srv.host)
logger.FatalLevel.LogErrorCtxf(logger.NilLevel, "Listen Server '%s'", err, srv.host)
}
}()
}
@@ -244,7 +242,7 @@ func (srv *modelServer) Restart() {
}
func (srv *modelServer) Shutdown() {
InfoLevel.Logf("Shutdown Server '%s'...", srv.addr.Host)
logger.InfoLevel.Logf("Shutdown Server '%s'...", srv.addr.Host)
ctx, cancel := context.WithTimeout(context.Background(), TIMEOUT_10_SEC)
defer cancel()
@@ -254,7 +252,7 @@ func (srv *modelServer) Shutdown() {
}
if err := srv.srv.Shutdown(ctx); err != nil {
FatalLevel.Logf("Shutdown Server '%s' Error: %v", srv.host, err)
logger.FatalLevel.Logf("Shutdown Server '%s' Error: %v", srv.host, err)
}
srv.srv = nil