mirror of
https://github.com/kataras/iris.git
synced 2025-02-02 15:30:36 +01:00
Alt the port part on subdomains if 80 or 443 in order to work as expected by devs
Former-commit-id: a7603e50591624c4b7a56448fe17b7b62a2de1ba
This commit is contained in:
parent
847a59386f
commit
eaa3c91d51
|
@ -685,6 +685,15 @@ func (mux *serveMux) getTree(method string, subdomain string) *muxTree {
|
|||
}
|
||||
|
||||
func (mux *serveMux) buildHandler(pool iris.ContextPool) http.Handler {
|
||||
|
||||
hostname := pool.Framework().Config.VHost
|
||||
// check if VHost is mydomain.com:80 || mydomain.com:443 before serving
|
||||
// means that the port part is optional and a valid client can make a request without the port.
|
||||
hostPort := iris.ParsePort(hostname)
|
||||
if hostPort == 80 || hostPort == 443 {
|
||||
hostname = iris.ParseHostname(hostname) // remove the port part.
|
||||
}
|
||||
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
pool.Run(w, r, func(context *iris.Context) {
|
||||
routePath := context.Path()
|
||||
|
@ -697,7 +706,6 @@ func (mux *serveMux) buildHandler(pool iris.ContextPool) http.Handler {
|
|||
if mux.hosts && tree.subdomain != "" {
|
||||
|
||||
requestHost := context.Host()
|
||||
hostname := context.Framework().Config.VHost
|
||||
// println("mux are true and tree.subdomain= " + tree.subdomain + "and hostname = " + hostname + " host = " + requestHost)
|
||||
if requestHost != hostname {
|
||||
// we have a subdomain
|
||||
|
|
Loading…
Reference in New Issue
Block a user