MethodOverride 中间件检查从请求中重写的方法,并使用它来代替原来的方法。
出于安全原因,只有POST方法可以被重写。
POST
使用
e.Pre(middleware.MethodOverride())
e := echo.New() e.Pre(middleware.MethodOverrideWithConfig(middleware.MethodOverrideConfig{ Getter: middleware.MethodFromForm("_method"), }))
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 }
DefaultMethodOverrideConfig = MethodOverrideConfig{ Skipper: defaultSkipper, Getter: MethodFromHeader(echo.HeaderXHTTPMethodOverride), }
Copyright© 2013-2020
All Rights Reserved 京ICP备2023019179号-8