requestbodyvar

package module
v0.0.0-...-b344e23 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 24, 2020 License: MIT Imports: 9 Imported by: 0

README

caddy-requestbodyvar

Caddy v2 module to add support for the missing {http.request.body.*} placeholder (variable).

Installation

$ xcaddy build --with github.com/RussellLuo/caddy-requestbodyvar

Example

With the following Caddyfile:

localhost:8080 {
    route / {
        request_body_var

        respond {http.request.body.name}
    }
}

You can get the responses as below:

$ curl -XPSOT https://localhost:8080 -d '{"name":"caddy"}'
caddy
$ curl -XPSOT https://localhost:8080 -d '{"name":"wow"}'
wow

License

MIT

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type RequestBodyVar

type RequestBodyVar struct{}

RequestBodyVar implements an HTTP handler that replaces {http.request.body.*} with the value of the given field from request body, if any.

func (RequestBodyVar) CaddyModule

func (RequestBodyVar) CaddyModule() caddy.ModuleInfo

CaddyModule returns the Caddy module information.

func (RequestBodyVar) ServeHTTP

ServeHTTP implements caddyhttp.MiddlewareHandler.

func (*RequestBodyVar) UnmarshalCaddyfile

func (m *RequestBodyVar) UnmarshalCaddyfile(d *caddyfile.Dispenser) error

UnmarshalCaddyfile - this is a no-op

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL