1
0
mirror of https://github.com/labstack/echo.git synced 2025-05-27 23:07:33 +02:00

Bumped to v1.3

Signed-off-by: Vishal Rana <vr@labstack.com>
This commit is contained in:
Vishal Rana 2015-12-01 11:22:45 -08:00
parent f54cdd86d0
commit 9650c39055
13 changed files with 86 additions and 68 deletions

View File

@ -142,7 +142,7 @@ func (c *Context) HTML(code int, html string) (err error) {
// String sends a string response with status code. // String sends a string response with status code.
func (c *Context) String(code int, s string) (err error) { func (c *Context) String(code int, s string) (err error) {
c.response.Header().Set(ContentType, TextPlain) c.response.Header().Set(ContentType, TextPlainCharsetUTF8)
c.response.WriteHeader(code) c.response.WriteHeader(code)
c.response.Write([]byte(s)) c.response.Write([]byte(s))
return return
@ -255,6 +255,11 @@ func (c *Context) Error(err error) {
c.echo.httpErrorHandler(err, c) c.echo.httpErrorHandler(err, c)
} }
// Echo returns the `Echo` instance.
func (c *Context) Echo() *Echo {
return c.echo
}
func (c *Context) reset(r *http.Request, w http.ResponseWriter, e *Echo) { func (c *Context) reset(r *http.Request, w http.ResponseWriter, e *Echo) {
c.request = r c.request = r
c.response.reset(w) c.response.reset(w)

View File

@ -37,9 +37,10 @@ func TestContext(t *testing.T) {
var nonMarshallableChannel chan bool var nonMarshallableChannel chan bool
e := New()
req, _ := http.NewRequest(POST, "/", strings.NewReader(userJSON)) req, _ := http.NewRequest(POST, "/", strings.NewReader(userJSON))
rec := httptest.NewRecorder() rec := httptest.NewRecorder()
c := NewContext(req, NewResponse(rec), New()) c := NewContext(req, NewResponse(rec, e), e)
// Request // Request
assert.NotNil(t, c.Request()) assert.NotNil(t, c.Request())
@ -96,7 +97,7 @@ func TestContext(t *testing.T) {
// JSON // JSON
rec = httptest.NewRecorder() rec = httptest.NewRecorder()
c = NewContext(req, NewResponse(rec), New()) c = NewContext(req, NewResponse(rec, e), e)
err = c.JSON(http.StatusOK, user{"1", "Joe"}) err = c.JSON(http.StatusOK, user{"1", "Joe"})
if assert.NoError(t, err) { if assert.NoError(t, err) {
assert.Equal(t, http.StatusOK, rec.Code) assert.Equal(t, http.StatusOK, rec.Code)
@ -106,14 +107,14 @@ func TestContext(t *testing.T) {
// JSON (error) // JSON (error)
rec = httptest.NewRecorder() rec = httptest.NewRecorder()
c = NewContext(req, NewResponse(rec), New()) c = NewContext(req, NewResponse(rec, e), e)
val := make(chan bool) val := make(chan bool)
err = c.JSON(http.StatusOK, val) err = c.JSON(http.StatusOK, val)
assert.Error(t, err) assert.Error(t, err)
// JSONIndent // JSONIndent
rec = httptest.NewRecorder() rec = httptest.NewRecorder()
c = NewContext(req, NewResponse(rec), New()) c = NewContext(req, NewResponse(rec, e), e)
err = c.JSONIndent(http.StatusOK, user{"1", "Joe"}, "_", "?") err = c.JSONIndent(http.StatusOK, user{"1", "Joe"}, "_", "?")
if assert.NoError(t, err) { if assert.NoError(t, err) {
assert.Equal(t, http.StatusOK, rec.Code) assert.Equal(t, http.StatusOK, rec.Code)
@ -123,13 +124,13 @@ func TestContext(t *testing.T) {
// JSONIndent (error) // JSONIndent (error)
rec = httptest.NewRecorder() rec = httptest.NewRecorder()
c = NewContext(req, NewResponse(rec), New()) c = NewContext(req, NewResponse(rec, e), e)
err = c.JSONIndent(http.StatusOK, nonMarshallableChannel, "_", "?") err = c.JSONIndent(http.StatusOK, nonMarshallableChannel, "_", "?")
assert.Error(t, err) assert.Error(t, err)
// JSONP // JSONP
rec = httptest.NewRecorder() rec = httptest.NewRecorder()
c = NewContext(req, NewResponse(rec), New()) c = NewContext(req, NewResponse(rec, e), e)
callback := "callback" callback := "callback"
err = c.JSONP(http.StatusOK, callback, user{"1", "Joe"}) err = c.JSONP(http.StatusOK, callback, user{"1", "Joe"})
if assert.NoError(t, err) { if assert.NoError(t, err) {
@ -140,7 +141,7 @@ func TestContext(t *testing.T) {
// XML // XML
rec = httptest.NewRecorder() rec = httptest.NewRecorder()
c = NewContext(req, NewResponse(rec), New()) c = NewContext(req, NewResponse(rec, e), e)
err = c.XML(http.StatusOK, user{"1", "Joe"}) err = c.XML(http.StatusOK, user{"1", "Joe"})
if assert.NoError(t, err) { if assert.NoError(t, err) {
assert.Equal(t, http.StatusOK, rec.Code) assert.Equal(t, http.StatusOK, rec.Code)
@ -150,13 +151,13 @@ func TestContext(t *testing.T) {
// XML (error) // XML (error)
rec = httptest.NewRecorder() rec = httptest.NewRecorder()
c = NewContext(req, NewResponse(rec), New()) c = NewContext(req, NewResponse(rec, e), e)
err = c.XML(http.StatusOK, nonMarshallableChannel) err = c.XML(http.StatusOK, nonMarshallableChannel)
assert.Error(t, err) assert.Error(t, err)
// XMLIndent // XMLIndent
rec = httptest.NewRecorder() rec = httptest.NewRecorder()
c = NewContext(req, NewResponse(rec), New()) c = NewContext(req, NewResponse(rec, e), e)
err = c.XMLIndent(http.StatusOK, user{"1", "Joe"}, "_", "?") err = c.XMLIndent(http.StatusOK, user{"1", "Joe"}, "_", "?")
if assert.NoError(t, err) { if assert.NoError(t, err) {
assert.Equal(t, http.StatusOK, rec.Code) assert.Equal(t, http.StatusOK, rec.Code)
@ -166,23 +167,23 @@ func TestContext(t *testing.T) {
// XMLIndent (error) // XMLIndent (error)
rec = httptest.NewRecorder() rec = httptest.NewRecorder()
c = NewContext(req, NewResponse(rec), New()) c = NewContext(req, NewResponse(rec, e), e)
err = c.XMLIndent(http.StatusOK, nonMarshallableChannel, "_", "?") err = c.XMLIndent(http.StatusOK, nonMarshallableChannel, "_", "?")
assert.Error(t, err) assert.Error(t, err)
// String // String
rec = httptest.NewRecorder() rec = httptest.NewRecorder()
c = NewContext(req, NewResponse(rec), New()) c = NewContext(req, NewResponse(rec, e), e)
err = c.String(http.StatusOK, "Hello, World!") err = c.String(http.StatusOK, "Hello, World!")
if assert.NoError(t, err) { if assert.NoError(t, err) {
assert.Equal(t, http.StatusOK, rec.Code) assert.Equal(t, http.StatusOK, rec.Code)
assert.Equal(t, TextPlain, rec.Header().Get(ContentType)) assert.Equal(t, TextPlainCharsetUTF8, rec.Header().Get(ContentType))
assert.Equal(t, "Hello, World!", rec.Body.String()) assert.Equal(t, "Hello, World!", rec.Body.String())
} }
// HTML // HTML
rec = httptest.NewRecorder() rec = httptest.NewRecorder()
c = NewContext(req, NewResponse(rec), New()) c = NewContext(req, NewResponse(rec, e), e)
err = c.HTML(http.StatusOK, "Hello, <strong>World!</strong>") err = c.HTML(http.StatusOK, "Hello, <strong>World!</strong>")
if assert.NoError(t, err) { if assert.NoError(t, err) {
assert.Equal(t, http.StatusOK, rec.Code) assert.Equal(t, http.StatusOK, rec.Code)
@ -192,7 +193,7 @@ func TestContext(t *testing.T) {
// File // File
rec = httptest.NewRecorder() rec = httptest.NewRecorder()
c = NewContext(req, NewResponse(rec), New()) c = NewContext(req, NewResponse(rec, e), e)
err = c.File("test/fixture/walle.png", "", false) err = c.File("test/fixture/walle.png", "", false)
if assert.NoError(t, err) { if assert.NoError(t, err) {
assert.Equal(t, http.StatusOK, rec.Code) assert.Equal(t, http.StatusOK, rec.Code)
@ -201,7 +202,7 @@ func TestContext(t *testing.T) {
// File as attachment // File as attachment
rec = httptest.NewRecorder() rec = httptest.NewRecorder()
c = NewContext(req, NewResponse(rec), New()) c = NewContext(req, NewResponse(rec, e), e)
err = c.File("test/fixture/walle.png", "WALLE.PNG", true) err = c.File("test/fixture/walle.png", "WALLE.PNG", true)
if assert.NoError(t, err) { if assert.NoError(t, err) {
assert.Equal(t, http.StatusOK, rec.Code) assert.Equal(t, http.StatusOK, rec.Code)
@ -211,23 +212,23 @@ func TestContext(t *testing.T) {
// NoContent // NoContent
rec = httptest.NewRecorder() rec = httptest.NewRecorder()
c = NewContext(req, NewResponse(rec), New()) c = NewContext(req, NewResponse(rec, e), e)
c.NoContent(http.StatusOK) c.NoContent(http.StatusOK)
assert.Equal(t, http.StatusOK, c.response.status) assert.Equal(t, http.StatusOK, c.response.status)
// Redirect // Redirect
rec = httptest.NewRecorder() rec = httptest.NewRecorder()
c = NewContext(req, NewResponse(rec), New()) c = NewContext(req, NewResponse(rec, e), e)
assert.Equal(t, nil, c.Redirect(http.StatusMovedPermanently, "http://labstack.github.io/echo")) assert.Equal(t, nil, c.Redirect(http.StatusMovedPermanently, "http://labstack.github.io/echo"))
// Error // Error
rec = httptest.NewRecorder() rec = httptest.NewRecorder()
c = NewContext(req, NewResponse(rec), New()) c = NewContext(req, NewResponse(rec, e), e)
c.Error(errors.New("error")) c.Error(errors.New("error"))
assert.Equal(t, http.StatusInternalServerError, c.response.status) assert.Equal(t, http.StatusInternalServerError, c.response.status)
// reset // reset
c.reset(req, NewResponse(httptest.NewRecorder()), New()) c.reset(req, NewResponse(httptest.NewRecorder(), e), e)
} }
func TestContextPath(t *testing.T) { func TestContextPath(t *testing.T) {

40
echo.go
View File

@ -36,6 +36,7 @@ type (
debug bool debug bool
hook http.HandlerFunc hook http.HandlerFunc
autoIndex bool autoIndex bool
logger *log.Logger
router *Router router *Router
} }
@ -181,8 +182,6 @@ var (
} }
unixEpochTime = time.Unix(0, 0) unixEpochTime = time.Unix(0, 0)
logger = log.New("echo")
) )
// New creates an instance of Echo. // New creates an instance of Echo.
@ -211,14 +210,14 @@ func New() (e *Echo) {
if !c.response.committed { if !c.response.committed {
http.Error(c.response, msg, code) http.Error(c.response, msg, code)
} }
log.Error(err) e.logger.Error(err)
} }
e.SetHTTPErrorHandler(e.defaultHTTPErrorHandler) e.SetHTTPErrorHandler(e.defaultHTTPErrorHandler)
e.SetBinder(&binder{}) e.SetBinder(&binder{})
// Logger // Logger
log.SetPrefix("echo") e.logger = log.New("echo")
log.SetLevel(log.INFO) e.logger.SetLevel(log.INFO)
return return
} }
@ -228,14 +227,24 @@ func (e *Echo) Router() *Router {
return e.router return e.router
} }
// SetOutput sets the output destination for the logger. // SetLogPrefix sets the prefix for the logger. Default value is `echo`.
func SetOutput(w io.Writer) { func (e *Echo) SetLogPrefix(prefix string) {
log.SetOutput(w) e.logger.SetPrefix(prefix)
} }
// SetLogLevel sets the log level for global logger. The default value is `log.INFO`. // SetLogOutput sets the output destination for the logger. Default value is `os.Std*`
func SetLogLevel(l log.Level) { func (e *Echo) SetLogOutput(w io.Writer) {
log.SetLevel(l) e.logger.SetOutput(w)
}
// SetLogLevel sets the log level for the logger. Default value is `log.INFO`.
func (e *Echo) SetLogLevel(l log.Level) {
e.logger.SetLevel(l)
}
// Logger returns the logger instance.
func (e *Echo) Logger() *log.Logger {
return e.logger
} }
// HTTP2 enables/disables HTTP2 support. // HTTP2 enables/disables HTTP2 support.
@ -273,8 +282,7 @@ func (e *Echo) Debug() bool {
return e.debug return e.debug
} }
// AutoIndex enables/disables automatically creates a directory listing if the directory // AutoIndex enables/disables automatically creating an index page for the directory.
// doesn't contain an index page.
func (e *Echo) AutoIndex(on bool) { func (e *Echo) AutoIndex(on bool) {
e.autoIndex = on e.autoIndex = on
} }
@ -575,11 +583,11 @@ func (e *Echo) run(s *http.Server, files ...string) {
http2.ConfigureServer(s, nil) http2.ConfigureServer(s, nil)
} }
if len(files) == 0 { if len(files) == 0 {
log.Fatal(s.ListenAndServe()) e.logger.Fatal(s.ListenAndServe())
} else if len(files) == 2 { } else if len(files) == 2 {
log.Fatal(s.ListenAndServeTLS(files[0], files[1])) e.logger.Fatal(s.ListenAndServeTLS(files[0], files[1]))
} else { } else {
log.Fatal("invalid TLS configuration") e.logger.Fatal("invalid TLS configuration")
} }
} }

View File

@ -27,7 +27,7 @@ func TestEcho(t *testing.T) {
e := New() e := New()
req, _ := http.NewRequest(GET, "/", nil) req, _ := http.NewRequest(GET, "/", nil)
rec := httptest.NewRecorder() rec := httptest.NewRecorder()
c := NewContext(req, NewResponse(rec), e) c := NewContext(req, NewResponse(rec, e), e)
// Router // Router
assert.NotNil(t, e.Router()) assert.NotNil(t, e.Router())

View File

@ -11,9 +11,10 @@ import (
) )
func TestBasicAuth(t *testing.T) { func TestBasicAuth(t *testing.T) {
e := echo.New()
req, _ := http.NewRequest(echo.GET, "/", nil) req, _ := http.NewRequest(echo.GET, "/", nil)
rec := httptest.NewRecorder() rec := httptest.NewRecorder()
c := echo.NewContext(req, echo.NewResponse(rec), echo.New()) c := echo.NewContext(req, echo.NewResponse(rec, e), e)
fn := func(u, p string) bool { fn := func(u, p string) bool {
if u == "joe" && p == "secret" { if u == "joe" && p == "secret" {
return true return true

View File

@ -33,9 +33,10 @@ func (c *closeNotifyingRecorder) CloseNotify() <-chan bool {
} }
func TestGzip(t *testing.T) { func TestGzip(t *testing.T) {
e := echo.New()
req, _ := http.NewRequest(echo.GET, "/", nil) req, _ := http.NewRequest(echo.GET, "/", nil)
rec := httptest.NewRecorder() rec := httptest.NewRecorder()
c := echo.NewContext(req, echo.NewResponse(rec), echo.New()) c := echo.NewContext(req, echo.NewResponse(rec, e), e)
h := func(c *echo.Context) error { h := func(c *echo.Context) error {
c.Response().Write([]byte("test")) // For Content-Type sniffing c.Response().Write([]byte("test")) // For Content-Type sniffing
return nil return nil
@ -49,7 +50,7 @@ func TestGzip(t *testing.T) {
req, _ = http.NewRequest(echo.GET, "/", nil) req, _ = http.NewRequest(echo.GET, "/", nil)
req.Header.Set(echo.AcceptEncoding, "gzip") req.Header.Set(echo.AcceptEncoding, "gzip")
rec = httptest.NewRecorder() rec = httptest.NewRecorder()
c = echo.NewContext(req, echo.NewResponse(rec), echo.New()) c = echo.NewContext(req, echo.NewResponse(rec, e), e)
// Gzip // Gzip
Gzip()(h)(c) Gzip()(h)(c)
@ -121,7 +122,6 @@ func TestGzipCloseNotify(t *testing.T) {
} }
func BenchmarkGzip(b *testing.B) { func BenchmarkGzip(b *testing.B) {
b.StopTimer() b.StopTimer()
b.ReportAllocs() b.ReportAllocs()
@ -135,8 +135,9 @@ func BenchmarkGzip(b *testing.B) {
b.StartTimer() b.StartTimer()
for i := 0; i < b.N; i++ { for i := 0; i < b.N; i++ {
e := echo.New()
rec := httptest.NewRecorder() rec := httptest.NewRecorder()
c := echo.NewContext(req, echo.NewResponse(rec), echo.New()) c := echo.NewContext(req, echo.NewResponse(rec, e), e)
Gzip()(h)(c) Gzip()(h)(c)
} }

View File

@ -6,7 +6,6 @@ import (
"github.com/labstack/echo" "github.com/labstack/echo"
"github.com/labstack/gommon/color" "github.com/labstack/gommon/color"
"github.com/labstack/gommon/log"
) )
func Logger() echo.MiddlewareFunc { func Logger() echo.MiddlewareFunc {
@ -14,6 +13,7 @@ func Logger() echo.MiddlewareFunc {
return func(c *echo.Context) error { return func(c *echo.Context) error {
req := c.Request() req := c.Request()
res := c.Response() res := c.Response()
logger := c.Echo().Logger()
remoteAddr := req.RemoteAddr remoteAddr := req.RemoteAddr
if ip := req.Header.Get(echo.XRealIP); ip != "" { if ip := req.Header.Get(echo.XRealIP); ip != "" {
@ -47,7 +47,7 @@ func Logger() echo.MiddlewareFunc {
code = color.Cyan(n) code = color.Cyan(n)
} }
log.Info("%s %s %s %s %s %d", remoteAddr, method, path, code, stop.Sub(start), size) logger.Info("%s %s %s %s %s %d", remoteAddr, method, path, code, stop.Sub(start), size)
return nil return nil
} }
} }

View File

@ -8,7 +8,6 @@ import (
"testing" "testing"
"github.com/labstack/echo" "github.com/labstack/echo"
"github.com/labstack/gommon/log"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
) )
@ -17,7 +16,7 @@ func TestLogger(t *testing.T) {
e := echo.New() e := echo.New()
req, _ := http.NewRequest(echo.GET, "/", nil) req, _ := http.NewRequest(echo.GET, "/", nil)
rec := httptest.NewRecorder() rec := httptest.NewRecorder()
c := echo.NewContext(req, echo.NewResponse(rec), e) c := echo.NewContext(req, echo.NewResponse(rec, e), e)
// Status 2xx // Status 2xx
h := func(c *echo.Context) error { h := func(c *echo.Context) error {
@ -27,7 +26,7 @@ func TestLogger(t *testing.T) {
// Status 3xx // Status 3xx
rec = httptest.NewRecorder() rec = httptest.NewRecorder()
c = echo.NewContext(req, echo.NewResponse(rec), e) c = echo.NewContext(req, echo.NewResponse(rec, e), e)
h = func(c *echo.Context) error { h = func(c *echo.Context) error {
return c.String(http.StatusTemporaryRedirect, "test") return c.String(http.StatusTemporaryRedirect, "test")
} }
@ -35,7 +34,7 @@ func TestLogger(t *testing.T) {
// Status 4xx // Status 4xx
rec = httptest.NewRecorder() rec = httptest.NewRecorder()
c = echo.NewContext(req, echo.NewResponse(rec), e) c = echo.NewContext(req, echo.NewResponse(rec, e), e)
h = func(c *echo.Context) error { h = func(c *echo.Context) error {
return c.String(http.StatusNotFound, "test") return c.String(http.StatusNotFound, "test")
} }
@ -44,7 +43,7 @@ func TestLogger(t *testing.T) {
// Status 5xx with empty path // Status 5xx with empty path
req, _ = http.NewRequest(echo.GET, "", nil) req, _ = http.NewRequest(echo.GET, "", nil)
rec = httptest.NewRecorder() rec = httptest.NewRecorder()
c = echo.NewContext(req, echo.NewResponse(rec), e) c = echo.NewContext(req, echo.NewResponse(rec, e), e)
h = func(c *echo.Context) error { h = func(c *echo.Context) error {
return errors.New("error") return errors.New("error")
} }
@ -52,14 +51,13 @@ func TestLogger(t *testing.T) {
} }
func TestLoggerIPAddress(t *testing.T) { func TestLoggerIPAddress(t *testing.T) {
buf := &bytes.Buffer{}
log.SetOutput(buf)
ip := "127.0.0.1"
e := echo.New() e := echo.New()
req, _ := http.NewRequest(echo.GET, "/", nil) req, _ := http.NewRequest(echo.GET, "/", nil)
rec := httptest.NewRecorder() rec := httptest.NewRecorder()
c := echo.NewContext(req, echo.NewResponse(rec), e) c := echo.NewContext(req, echo.NewResponse(rec, e), e)
buf := new(bytes.Buffer)
e.Logger().SetOutput(buf)
ip := "127.0.0.1"
h := func(c *echo.Context) error { h := func(c *echo.Context) error {
return c.String(http.StatusOK, "test") return c.String(http.StatusOK, "test")
} }

View File

@ -14,7 +14,7 @@ func TestRecover(t *testing.T) {
e.SetDebug(true) e.SetDebug(true)
req, _ := http.NewRequest(echo.GET, "/", nil) req, _ := http.NewRequest(echo.GET, "/", nil)
rec := httptest.NewRecorder() rec := httptest.NewRecorder()
c := echo.NewContext(req, echo.NewResponse(rec), e) c := echo.NewContext(req, echo.NewResponse(rec, e), e)
h := func(c *echo.Context) error { h := func(c *echo.Context) error {
panic("test") panic("test")
} }

View File

@ -28,7 +28,6 @@ func main() {
} }
fmt.Println(msg) fmt.Println(msg)
} }
return
}) })
e.Run(":1323") e.Run(":1323")

View File

@ -4,8 +4,6 @@ import (
"bufio" "bufio"
"net" "net"
"net/http" "net/http"
"github.com/labstack/gommon/log"
) )
type ( type (
@ -14,11 +12,12 @@ type (
status int status int
size int64 size int64
committed bool committed bool
echo *Echo
} }
) )
func NewResponse(w http.ResponseWriter) *Response { func NewResponse(w http.ResponseWriter, e *Echo) *Response {
return &Response{writer: w} return &Response{writer: w, echo: e}
} }
func (r *Response) SetWriter(w http.ResponseWriter) { func (r *Response) SetWriter(w http.ResponseWriter) {
@ -35,7 +34,7 @@ func (r *Response) Writer() http.ResponseWriter {
func (r *Response) WriteHeader(code int) { func (r *Response) WriteHeader(code int) {
if r.committed { if r.committed {
log.Warn("response already committed") r.echo.Logger().Warn("response already committed")
return return
} }
r.status = code r.status = code

View File

@ -9,8 +9,9 @@ import (
) )
func TestResponse(t *testing.T) { func TestResponse(t *testing.T) {
e := New()
w := httptest.NewRecorder() w := httptest.NewRecorder()
r := NewResponse(w) r := NewResponse(w, e)
// SetWriter // SetWriter
r.SetWriter(w) r.SetWriter(w)

View File

@ -25,17 +25,23 @@ and message `HTTPError.Message`.
Enables/disables debug mode. Enables/disables debug mode.
## Log prefix
`echo#SetLogPrefix(prefix string)`
SetLogPrefix sets the prefix for the logger. Default value is `echo`.
### Log output ### Log output
`echo#SetOutput(w io.Writer)` `echo#SetLogOutput(w io.Writer)`
SetOutput sets the output destination for the global logger. SetLogOutput sets the output destination for the logger. Default value is `os.Std*`
### Log level ### Log level
`echo#SetLogLevel(l log.Level)` `echo#SetLogLevel(l log.Level)`
SetLogLevel sets the log level for global logger. The default value is `log.INFO`. SetLogLevel sets the log level for the logger. Default value is `log.INFO`.
### HTTP2 ### HTTP2
@ -47,8 +53,7 @@ HTTP2 enables/disables HTTP2 support.
`Echo#AutoIndex(on bool)` `Echo#AutoIndex(on bool)`
AutoIndex enables/disables automatically creates a directory listing if the directory doesn't AutoIndex enables/disables automatically creating an index page for the directory.
contain an index page.
*Example* *Example*
@ -63,7 +68,7 @@ Browse to `http://localhost:1323/` to see the directory listing.
### Hook ### Hook
`Echo#Hook(http.HandlerFunc)` `Echo#Hook(h http.HandlerFunc)`
Hook registers a callback which is invoked from `Echo#ServerHTTP` as the first Hook registers a callback which is invoked from `Echo#ServerHTTP` as the first
statement. Hook is useful if you want to modify response/response objects even statement. Hook is useful if you want to modify response/response objects even