mirror of
https://github.com/yusing/godoxy.git
synced 2026-04-23 01:08:47 +02:00
[BREAKING] added entrypoint middleware support and config, config schema update
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
||||
"errors"
|
||||
"io"
|
||||
"log"
|
||||
"net"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
@@ -57,7 +58,11 @@ func NewServer(opt Options) (s *Server) {
|
||||
}
|
||||
|
||||
if certAvailable && opt.RedirectToHTTPS && opt.HTTPSAddr != "" {
|
||||
httpHandler = redirectToTLSHandler(opt.HTTPSAddr)
|
||||
_, port, err := net.SplitHostPort(opt.HTTPSAddr)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
httpHandler = redirectToTLSHandler(port)
|
||||
} else {
|
||||
httpHandler = opt.Handler
|
||||
}
|
||||
@@ -151,7 +156,7 @@ func (s *Server) handleErr(scheme string, err error) {
|
||||
func redirectToTLSHandler(port string) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
r.URL.Scheme = "https"
|
||||
r.URL.Host = r.URL.Hostname() + port
|
||||
r.URL.Host = r.URL.Hostname() + ":" + port
|
||||
|
||||
var redirectCode int
|
||||
if r.Method == http.MethodGet {
|
||||
|
||||
Reference in New Issue
Block a user