Otherwise, the `http.ResponseWriter` passed to `next()` within the
middleware is unused. This precludes middlewares from wrapping the
http.ResponseWriter to do things like record the status code.
* Added feature to map url params to a struct with the default binder
* Added test for mix of POST data and bound params
* Renamed variables
* Added error check
* Removed unneded fix
* feat: Add a new ErrorHandlerWithContext
This commit adds a new error handler, which is passed the
current context, so that you can add custom redirects or even
other kinds of responses. For example:
```go
e.Use(middleware.JWTWithConfig(middleware.JWTConfig{
SigningKey: []byte("secret"),
TokenLookup: "query:token",
ErrorHandlerWithContext: func(err error, c echo.Context) error {
// do stuff with context and err
switch err.(type) {
case jwt.ValidationError:
return c.Redirect(http.StatusSeeOther, "/login")
}
return err
},
}))
```
* chore: address golint issues
* echo.context.cjson should encode the JSON before writing the status code #1334 :
`response.Write` automatically sets status to `200` if a response code wasn't committed yet. This is convenient, but it ignores the fact that `response.Status` is a public field that may be set separately/before `response.Write` has been called
A `response.Status` is by default `0`, or `200` if the response was reset, so `response.Write` should fallback to `200` only if a code wasn't set yet.
* echo.context.cjson should encode the JSON before writing the status code #1334 :
Writing the response code before encoding the payload is prone to error.
If JSON encoding fails, the response code is already committed, the server is able to only modify the response body to reflect the error and the user receives an awkward response where the status is successful but the body reports an error.
Instead - set the desired code on `c.response.Status`. If writing eventually takes place, the desired code is committed. If an error occurs, the server can still change the response.
* Set subdomains to AllowOrigins with wildcard
* Create IsSubDomain
* Avoid panic when pattern length smaller than domain length
* Change names, improve formula
* Test context path.
* Test context handler.
* Test handler error.
* Text context validate.
* Test context query string.
* Test context undefined param.
* Test context request.
* Test context scheme.
* Test context is websocket.
* Test context multipart form params with error.
* Text context bind.
* Text context logger.
* Text context xml response write error.
* Test context real ip.
If `certFile` or `keyFile` is `string` the values are treated as file paths.
If `certFile` or `keyFile` is `[]byte` the values are treated as the certificate or key as-is.
This reintroduces support for Go modules, as v4.
CloseNotifier() is removed as it has been obsoleted, see https://golang.org/doc/go1.11#net/http
It was already NOT working (not sending signals) as of 1.11 the functionality was gone, we merely
deleted the functions that exposed it. If anyone still relies on it they should migrate to using
`c.Request().Context().Done()` instead.
Closes#1268, #1255