mirror of
https://github.com/caddyserver/caddy.git
synced 2026-06-25 03:16:29 +00:00
rewrite: Add method Caddyfile directive (#4528)
This commit is contained in:
parent
6e6ce2be6b
commit
bcb7a19cd3
3 changed files with 48 additions and 1 deletions
|
|
@ -27,6 +27,7 @@ import (
|
|||
|
||||
func init() {
|
||||
httpcaddyfile.RegisterHandlerDirective("rewrite", parseCaddyfileRewrite)
|
||||
httpcaddyfile.RegisterHandlerDirective("method", parseCaddyfileMethod)
|
||||
httpcaddyfile.RegisterHandlerDirective("uri", parseCaddyfileURI)
|
||||
httpcaddyfile.RegisterDirective("handle_path", parseCaddyfileHandlePath)
|
||||
}
|
||||
|
|
@ -51,6 +52,24 @@ func parseCaddyfileRewrite(h httpcaddyfile.Helper) (caddyhttp.MiddlewareHandler,
|
|||
return rewr, nil
|
||||
}
|
||||
|
||||
// parseCaddyfileMethod sets up a basic method rewrite handler from Caddyfile tokens. Syntax:
|
||||
//
|
||||
// method [<matcher>] <method>
|
||||
//
|
||||
func parseCaddyfileMethod(h httpcaddyfile.Helper) (caddyhttp.MiddlewareHandler, error) {
|
||||
var rewr Rewrite
|
||||
for h.Next() {
|
||||
if !h.NextArg() {
|
||||
return nil, h.ArgErr()
|
||||
}
|
||||
rewr.Method = h.Val()
|
||||
if h.NextArg() {
|
||||
return nil, h.ArgErr()
|
||||
}
|
||||
}
|
||||
return rewr, nil
|
||||
}
|
||||
|
||||
// parseCaddyfileURI sets up a handler for manipulating (but not "rewriting") the
|
||||
// URI from Caddyfile tokens. Syntax:
|
||||
//
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue