mirror of
https://github.com/duanhf2012/origin.git
synced 2026-02-16 00:44:42 +08:00
优化代码规范
This commit is contained in:
@@ -8,20 +8,20 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
var DefaultMaxHeaderBytes int = 1<<20
|
||||
var DefaultMaxHeaderBytes = 1 << 20
|
||||
|
||||
type CAFile struct {
|
||||
CertFile string
|
||||
Keyfile string
|
||||
Keyfile string
|
||||
}
|
||||
|
||||
type HttpServer struct {
|
||||
listenAddr string
|
||||
listenAddr string
|
||||
readTimeout time.Duration
|
||||
writeTimeout time.Duration
|
||||
|
||||
handler http.Handler
|
||||
caFileList []CAFile
|
||||
handler http.Handler
|
||||
caFileList []CAFile
|
||||
|
||||
httpServer *http.Server
|
||||
}
|
||||
@@ -39,7 +39,7 @@ func (slf *HttpServer) Start() {
|
||||
|
||||
func (slf *HttpServer) startListen() error {
|
||||
if slf.httpServer != nil {
|
||||
return errors.New("Duplicate start not allowed")
|
||||
return errors.New("duplicate start not allowed")
|
||||
}
|
||||
|
||||
var tlsCaList []tls.Certificate
|
||||
@@ -47,7 +47,7 @@ func (slf *HttpServer) startListen() error {
|
||||
for _, caFile := range slf.caFileList {
|
||||
cer, err := tls.LoadX509KeyPair(caFile.CertFile, caFile.Keyfile)
|
||||
if err != nil {
|
||||
log.Fatal("Load CA file is fail",log.String("error",err.Error()),log.String("certFile",caFile.CertFile),log.String("keyFile",caFile.Keyfile))
|
||||
log.Fatal("Load CA file is fail", log.String("error", err.Error()), log.String("certFile", caFile.CertFile), log.String("keyFile", caFile.Keyfile))
|
||||
return err
|
||||
}
|
||||
tlsCaList = append(tlsCaList, cer)
|
||||
@@ -74,14 +74,13 @@ func (slf *HttpServer) startListen() error {
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
log.Fatal("Listen failure",log.String("error",err.Error()),log.String("addr:",slf.listenAddr))
|
||||
log.Fatal("Listen failure", log.String("error", err.Error()), log.String("addr:", slf.listenAddr))
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
func (slf *HttpServer) SetCAFile(caFile []CAFile) {
|
||||
slf.caFileList = caFile
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user