mirror of
https://github.com/labstack/echo.git
synced 2024-12-24 20:14:31 +02:00
parent
f8117ac7b3
commit
609587e6eb
@ -244,6 +244,12 @@ Middleware | Description
|
||||
|
||||
##### [More...](https://labstack.com/echo/guide/middleware/)
|
||||
|
||||
#### Third-party Middleware
|
||||
|
||||
Middleware | Description
|
||||
:--- | :---
|
||||
[echoperm](https://github.com/xyproto/echoperm) | Keeping track of users, login states and permissions.
|
||||
|
||||
### Next
|
||||
|
||||
- Head over to [guide](https://labstack.com/echo/guide/installation/)
|
||||
|
@ -124,6 +124,9 @@ type (
|
||||
// Error invokes the registered HTTP error handler. Generally used by middleware.
|
||||
Error(err error)
|
||||
|
||||
// Handler returns the matched handler by router.
|
||||
Handler() HandlerFunc
|
||||
|
||||
// Logger returns the `Logger` instance.
|
||||
Logger() *log.Logger
|
||||
|
||||
@ -408,6 +411,10 @@ func (c *context) Echo() *Echo {
|
||||
return c.echo
|
||||
}
|
||||
|
||||
func (c *context) Handler() HandlerFunc {
|
||||
return c.handler
|
||||
}
|
||||
|
||||
func (c *context) Logger() *log.Logger {
|
||||
return c.echo.logger
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package echo
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"io"
|
||||
"net/http"
|
||||
@ -266,6 +267,21 @@ func TestContextServeContent(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestContextHandler(t *testing.T) {
|
||||
e := New()
|
||||
r := e.Router()
|
||||
b := new(bytes.Buffer)
|
||||
|
||||
r.Add(GET, "/handler", func(Context) error {
|
||||
_, err := b.Write([]byte("handler"))
|
||||
return err
|
||||
}, e)
|
||||
c := NewContext(nil, nil, e)
|
||||
r.Find(GET, "/handler", c)
|
||||
c.Handler()(c)
|
||||
assert.Equal(t, "handler", b.String())
|
||||
}
|
||||
|
||||
func testBindOk(t *testing.T, c Context, ct string) {
|
||||
c.Request().Header().Set(HeaderContentType, ct)
|
||||
u := new(user)
|
||||
|
Loading…
Reference in New Issue
Block a user