2023-05-25 16:08:56 -06:00
|
|
|
package srvhttps
|
|
|
|
|
|
|
|
import "fmt"
|
|
|
|
import "log"
|
|
|
|
import "net/http"
|
2023-05-26 11:05:22 -06:00
|
|
|
import "hnakra/router/config"
|
2023-05-25 16:08:56 -06:00
|
|
|
|
|
|
|
type Server struct {
|
|
|
|
underlying *http.Server
|
|
|
|
Config config.Config
|
|
|
|
Handler http.Handler
|
|
|
|
}
|
|
|
|
|
|
|
|
func (server *Server) ListenAndServe () 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,
|
|
|
|
}
|
|
|
|
|
|
|
|
log.Println(".// https on", server.underlying.Addr)
|
|
|
|
return server.underlying.ListenAndServeTLS("", "")
|
|
|
|
}
|
|
|
|
|
|
|
|
func (server *Server) Close () error {
|
|
|
|
return server.underlying.Close()
|
|
|
|
}
|