Changed name of router to hn-router
This commit is contained in:
40
cmd/hn-router/srvhttps/https.go
Normal file
40
cmd/hn-router/srvhttps/https.go
Normal file
@@ -0,0 +1,40 @@
|
||||
package srvhttps
|
||||
|
||||
import "fmt"
|
||||
import "log"
|
||||
import "net/http"
|
||||
import "hnakra/router/config"
|
||||
|
||||
type Server struct {
|
||||
underlying *http.Server
|
||||
Config config.Config
|
||||
Handler http.Handler
|
||||
|
||||
running bool
|
||||
}
|
||||
|
||||
func (server *Server) Run () error {
|
||||
server.underlying = &http.Server {
|
||||
Addr: fmt.Sprint(":", server.Config.HTTPSPort()),
|
||||
// ReadHeaderTimeout: timeoutReadHeader * time.Second,
|
||||
// ReadTimeout: timeoutRead * time.Second,
|
||||
// WriteTimeout: timeoutWrite * time.Second,
|
||||
// IdleTimeout: timeoutIdle * time.Second,
|
||||
TLSConfig: config.TLSConfigFor(server.Config),
|
||||
Handler: server.Handler,
|
||||
}
|
||||
|
||||
server.running = true
|
||||
log.Println(".// https on", server.underlying.Addr)
|
||||
err := server.underlying.ListenAndServeTLS("", "")
|
||||
if server.running {
|
||||
return err
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
func (server *Server) Shutdown () error {
|
||||
server.running = false
|
||||
return server.underlying.Close()
|
||||
}
|
||||
Reference in New Issue
Block a user