Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS
Mirrored from https://github.com/Slazee/caddy.git
Synced Nov 14, 05:15 UTC
Minor cleanups/improvements
Matthew Holt committed
Jun 21, 2019 at 08:08 UTC
70c788ce0c7f81f87d19850164031ce2e8158e72
2 files changed
+5
-10
modules/caddyhttp/caddyhttp.go
+2
-3
@@ -203,10 +203,9 @@ func (app *App) automaticHTTPS() error {
203
for _, m := range matcherSet {
204
if hm, ok := m.(*MatchHost); ok {
205
for _, d := range *hm {
206
- if !certmagic.HostQualifies(d) {
207
- continue
206
+ if certmagic.HostQualifies(d) {
207
+ domainSet[d] = struct{}{}
208
}
209
- domainSet[d] = struct{}{}
209
}
210
}
211
}
modules/caddyhttp/templates/tplcontext.go
+3
-7
@@ -117,12 +117,8 @@ func (c templateContext) Cookie(name string) string {
117
return ""
118
}
119
120
-// ReqHeader gets the value of a request header with field name.
121
-func (c templateContext) ReqHeader(name string) string {
122
- return c.Req.Header.Get(name)
123
-}
124
-
120
// Hostname gets the (remote) hostname of the client making the request.
121
+// Performance warning: This involves a DNS lookup.
122
func (c templateContext) Hostname() string {
123
ip := c.IP()
124
@@ -134,8 +130,8 @@ func (c templateContext) Hostname() string {
130
return hostnameList[0]
131
}
132
137
-// IP gets the (remote) IP address of the client making the request.
138
-func (c templateContext) IP() string {
133
+// RemoteIP gets the IP address of the client making the request.
134
+func (c templateContext) RemoteIP() string {
135
ip, _, err := net.SplitHostPort(c.Req.RemoteAddr)
136
if err != nil {
137
return c.Req.RemoteAddr