mirror of
https://github.com/kataras/iris.git
synced 2025-03-14 08:16:28 +01:00
Nothing special here - set the ability to set a virtual scheme for the server, used inside global tmpl helper funcs
This commit is contained in:
parent
8288161b30
commit
81019aa90d
|
@ -86,6 +86,11 @@ type Server struct {
|
||||||
//
|
//
|
||||||
// Default is empty ""
|
// Default is empty ""
|
||||||
VListeningAddr string
|
VListeningAddr string
|
||||||
|
// VScheme if setted to not empty value then all template's helper funcs prepends that as the url scheme instead of the real scheme
|
||||||
|
// server's .Scheme returns VScheme if not empty && differs from real scheme
|
||||||
|
//
|
||||||
|
// Default is empty ""
|
||||||
|
VScheme string
|
||||||
// Name the server's name, defaults to "iris".
|
// Name the server's name, defaults to "iris".
|
||||||
// You're free to change it, but I will trust you to don't, this is the only setting whose somebody, like me, can see if iris web framework is used
|
// You're free to change it, but I will trust you to don't, this is the only setting whose somebody, like me, can see if iris web framework is used
|
||||||
Name string
|
Name string
|
||||||
|
@ -133,6 +138,7 @@ func DefaultServer() Server {
|
||||||
RedirectTo: "",
|
RedirectTo: "",
|
||||||
Virtual: false,
|
Virtual: false,
|
||||||
VListeningAddr: "",
|
VListeningAddr: "",
|
||||||
|
VScheme: "",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
7
http.go
7
http.go
|
@ -333,6 +333,13 @@ func (s *Server) Scheme() string {
|
||||||
if s.IsSecure() || (s.Config.CertFile != "" && s.Config.KeyFile != "") {
|
if s.IsSecure() || (s.Config.CertFile != "" && s.Config.KeyFile != "") {
|
||||||
scheme = "https://"
|
scheme = "https://"
|
||||||
}
|
}
|
||||||
|
// but if virtual scheme is setted and it differs from the real scheme, return the vscheme
|
||||||
|
// the developer should set it correctly, http:// or https:// or anything at the future:P
|
||||||
|
vscheme := s.Config.VScheme
|
||||||
|
if len(vscheme) > 0 && vscheme != scheme {
|
||||||
|
return vscheme
|
||||||
|
}
|
||||||
|
|
||||||
return scheme
|
return scheme
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
5
iris.go
5
iris.go
|
@ -798,10 +798,7 @@ func (s *Framework) URL(routeName string, args ...interface{}) (url string) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
srv := s.Servers.Main()
|
srv := s.Servers.Main()
|
||||||
scheme := "http://"
|
scheme := s.Servers.Main().Scheme()
|
||||||
if srv.IsSecure() {
|
|
||||||
scheme = "https://"
|
|
||||||
}
|
|
||||||
|
|
||||||
host := srv.Host()
|
host := srv.Host()
|
||||||
arguments := args[0:]
|
arguments := args[0:]
|
||||||
|
|
Loading…
Reference in New Issue
Block a user