Skip to content

Commit eee38a6

Browse files
committed
Fixed #35
Signed-off-by: Vishal Rana <vr@labstack.com>
1 parent bb20660 commit eee38a6

File tree

5 files changed

+32
-11
lines changed

5 files changed

+32
-11
lines changed

context.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ func (c *Context) NoContent(code int) error {
8080
}
8181

8282
// Error invokes the registered HTTP error handler.
83-
func (c *Context) Error(err error) {
84-
c.echo.httpErrorHandler(err, c)
83+
func (c *Context) Error(code int, err error) {
84+
c.echo.httpErrorHandler(code, err, c)
8585
}
8686

8787
// Get retrieves data from the context.

echo.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ type (
3535
HandlerFunc func(*Context) error
3636

3737
// HTTPErrorHandler is a centralized HTTP error handler.
38-
HTTPErrorHandler func(error, *Context)
38+
HTTPErrorHandler func(int, error, *Context)
3939

4040
BindFunc func(*http.Request, interface{}) error
4141

@@ -122,11 +122,11 @@ func New() (e *Echo) {
122122
e.NotFoundHandler(func(c *Context) {
123123
http.Error(c.Response, http.StatusText(http.StatusNotFound), http.StatusNotFound)
124124
})
125-
e.HTTPErrorHandler(func(err error, c *Context) {
125+
e.HTTPErrorHandler(func(code int, err error, c *Context) {
126126
if err != nil {
127127
// TODO: Warning
128128
log.Printf("echo: %s", color.Yellow("http error handler not registered"))
129-
http.Error(c.Response, err.Error(), http.StatusInternalServerError)
129+
http.Error(c.Response, err.Error(), code)
130130
}
131131
})
132132
e.Binder(func(r *http.Request, v interface{}) error {
@@ -305,7 +305,7 @@ func (e *Echo) ServeHTTP(w http.ResponseWriter, r *http.Request) {
305305

306306
// Execute chain
307307
if err := h(c); err != nil {
308-
e.httpErrorHandler(err, c)
308+
e.httpErrorHandler(http.StatusInternalServerError, err, c)
309309
}
310310

311311
e.pool.Put(c)

middleware/logger.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package middleware
22

33
import (
44
"log"
5+
"net/http"
56
"time"
67

78
"github.com/labstack/echo"
@@ -12,7 +13,7 @@ func Logger(h echo.HandlerFunc) echo.HandlerFunc {
1213
return func(c *echo.Context) error {
1314
start := time.Now()
1415
if err := h(c); err != nil {
15-
c.Error(err)
16+
c.Error(http.StatusInternalServerError, err)
1617
}
1718
end := time.Now()
1819
m := c.Request.Method

website/docs/guide.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,19 @@
1-
# Coming soon...
1+
# Guide
2+
3+
---
4+
5+
## Installation
6+
7+
Go `~1.4.2`
8+
9+
Install the latest version of Echo `go get github.com/labstack/echo`
10+
11+
Upgrade Echo `go get -u github.com/labstack/echo`
12+
13+
### Using package manager
14+
15+
## Routing
16+
17+
## Request
18+
19+
## Response

website/docs/index.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,14 @@ Echo is a fast HTTP router (zero memory allocation) and micro web framework in G
3535
- Use a customized function to bind request body to a Go type.
3636
- Register a view render so you can use any HTML templating engine.
3737

38-
## Installation
38+
## Getting Started
3939

40-
- [Go](https://golang.org/doc/install) > 1.4.x
40+
### Installation
41+
42+
- Go `~1.4.2`
4143
- `go get github.com/labstack/echo`
4244

43-
##[Examples](https://github.com/labstack/echo/tree/master/examples)
45+
###[Examples](https://github.com/labstack/echo/tree/master/examples)
4446

4547
> Hello, World!
4648

0 commit comments

Comments
 (0)