@@ -63,8 +63,8 @@ below registers a route for method `GET`, path `/hello` and a handler which send
63
63
` Hello! ` response.
64
64
65
65
``` go
66
- echo.Get (" /hello" , func (*echo.Context ) {
67
- c.String (http.StatusOK , " Hello!" )
66
+ echo.Get (" /hello" , func (*echo.Context ) *HTTPError {
67
+ return c.String (http.StatusOK , " Hello!" )
68
68
})
69
69
```
70
70
@@ -83,14 +83,14 @@ index `echo.Context.P(i uint8) string`. Getting parameter by index gives a sligh
83
83
better performance.
84
84
85
85
``` go
86
- echo.Get (" /users/:id" , func (c *echo.Context ) {
86
+ echo.Get (" /users/:id" , func (c *echo.Context ) *HTTPError {
87
87
// By name
88
88
id := c.Param (" id" )
89
89
90
90
// By index
91
91
id := c.P (0 )
92
92
93
- c.String (http.StatusOK , id)
93
+ return c.String (http.StatusOK , id)
94
94
})
95
95
```
96
96
@@ -113,16 +113,16 @@ match
113
113
#### Example
114
114
115
115
``` go
116
- e.Get (" /users/:id" , func (c *echo.Context ) {
117
- c.String (http.StatusOK , " /users/:id" )
116
+ e.Get (" /users/:id" , func (c *echo.Context ) *HTTPError {
117
+ return c.String (http.StatusOK , " /users/:id" )
118
118
})
119
119
120
- e.Get (" /users/new" , func (c *echo.Context ) {
121
- c.String (http.StatusOK , " /users/new" )
120
+ e.Get (" /users/new" , func (c *echo.Context ) *HTTPError {
121
+ return c.String (http.StatusOK , " /users/new" )
122
122
})
123
123
124
- e.Get (" /users/1/files/*" , func (c *echo.Context ) {
125
- c.String (http.StatusOK , " /users/1/files/*" )
124
+ e.Get (" /users/1/files/*" , func (c *echo.Context ) *HTTPError {
125
+ return c.String (http.StatusOK , " /users/1/files/*" )
126
126
})
127
127
```
128
128
@@ -146,8 +146,8 @@ application.
146
146
147
147
``` go
148
148
// Handler
149
- h := func (*echo.Context ) {
150
- c.String (http.StatusOK , " OK" )
149
+ h := func (*echo.Context ) *HTTPError {
150
+ return c.String (http.StatusOK , " OK" )
151
151
}
152
152
153
153
// Route
@@ -161,23 +161,23 @@ e.Get("/users/:id", h)
161
161
### JSON
162
162
163
163
``` go
164
- context.JSON (code int , v interface {}) error
164
+ context.JSON (code int , v interface {}) *HTTPError
165
165
```
166
166
167
167
Sends a JSON response with status code.
168
168
169
169
### String
170
170
171
171
``` go
172
- context.String (code int , s string ) error
172
+ context.String (code int , s string ) *HTTPError
173
173
```
174
174
175
175
Sends a text/plain response with status code.
176
176
177
177
### HTML
178
178
179
179
``` go
180
- func (c *Context ) HTML (code int , html string ) error
180
+ func (c *Context ) HTML (code int , html string ) * HTTPError
181
181
```
182
182
183
183
Sends an HTML response with status code.
0 commit comments