1
0
mirror of https://github.com/labstack/echo.git synced 2025-01-05 22:53:57 +02:00
echo/website/content/middleware/method-override.md
Vishal Rana 73110004ef doc: updated, recipe: auto tls
Signed-off-by: Vishal Rana <vr@labstack.com>
2016-11-28 20:34:29 -08:00

1.1 KiB

+++ title = "Method Override Middleware" description = "Method override middleware for Echo" [menu.main] name = "Method Override" parent = "middleware" weight = 5 +++

Method override middleware checks for the overridden method from the request and uses it instead of the original method.

For security reasons, only POST method can be overridden.

Usage

e.Pre(middleware.MethodOverride())

Custom Configuration

Usage

e := echo.New()
e.Pre(middleware.MethodOverrideWithConfig(middleware.MethodOverrideConfig{
  Getter: middleware.MethodFromForm("_method"),
}))

Configuration

MethodOverrideConfig struct {
  // Skipper defines a function to skip middleware.
  Skipper Skipper

  // Getter is a function that gets overridden method from the request.
  // Optional. Default values MethodFromHeader(echo.HeaderXHTTPMethodOverride).
  Getter MethodOverrideGetter
}

Default Configuration

DefaultMethodOverrideConfig = MethodOverrideConfig{
  Skipper: defaultSkipper,
  Getter:  MethodFromHeader(echo.HeaderXHTTPMethodOverride),
}