summaryrefslogtreecommitdiff
path: root/modules/caddyhttp
diff options
context:
space:
mode:
authorMatthew Holt <mholt@users.noreply.github.com>2020-04-24 21:05:09 -0600
committerMatthew Holt <mholt@users.noreply.github.com>2020-04-24 21:05:09 -0600
commit02845bc9fdc3e9189d44f3bd30e8609cd59c97dd (patch)
tree798d7433a9c30615d3c3316d22f82174dc0f6a81 /modules/caddyhttp
parent97ed9e111d04718583c8e0cd141a464c993e224a (diff)
docs: Improve template documentation slightly; use const, not literal
Diffstat (limited to 'modules/caddyhttp')
-rw-r--r--modules/caddyhttp/reverseproxy/fastcgi/caddyfile.go3
-rw-r--r--modules/caddyhttp/templates/templates.go13
2 files changed, 15 insertions, 1 deletions
diff --git a/modules/caddyhttp/reverseproxy/fastcgi/caddyfile.go b/modules/caddyhttp/reverseproxy/fastcgi/caddyfile.go
index fdf9818..8924a6d 100644
--- a/modules/caddyhttp/reverseproxy/fastcgi/caddyfile.go
+++ b/modules/caddyhttp/reverseproxy/fastcgi/caddyfile.go
@@ -17,6 +17,7 @@ package fastcgi
import (
"encoding/json"
"net/http"
+ "strconv"
"github.com/caddyserver/caddy/v2"
"github.com/caddyserver/caddy/v2/caddyconfig"
@@ -136,7 +137,7 @@ func parsePHPFastCGI(h httpcaddyfile.Helper) ([]httpcaddyfile.ConfigValue, error
}),
}
redirHandler := caddyhttp.StaticResponse{
- StatusCode: caddyhttp.WeakString("308"),
+ StatusCode: caddyhttp.WeakString(strconv.Itoa(http.StatusPermanentRedirect)),
Headers: http.Header{"Location": []string{"{http.request.uri.path}/"}},
}
redirRoute := caddyhttp.Route{
diff --git a/modules/caddyhttp/templates/templates.go b/modules/caddyhttp/templates/templates.go
index d67b35b..f5df9be 100644
--- a/modules/caddyhttp/templates/templates.go
+++ b/modules/caddyhttp/templates/templates.go
@@ -113,6 +113,19 @@ func init() {
// {{.RemoteIP}}
// ```
//
+// ##### `.Req`
+//
+// Accesses the current HTTP request, which has various fields, including:
+//
+// - `.Method` - the method
+// - `.URL` - the URL, which in turn has component fields (Scheme, Host, Path, etc.)
+// - `.Header` - the header fields
+// - `.Host` - the Host or :authority header of the request
+//
+// ```
+// {{.Req.Header.Get "User-Agent"}}
+// ```
+//
// ##### `.RespHeader.Add`
//
// Adds a header field to the HTTP response.