@@ -26,13 +26,6 @@ import (
26
26
"time"
27
27
)
28
28
29
- type ResponseWriter interface {
30
- Header () http.Header
31
- WriteHeader (status int )
32
- Write (data []byte ) (n int , err error )
33
- Close ()
34
- }
35
-
36
29
// A Context object is created for every incoming HTTP request, and is
37
30
// passed to handlers as an optional first argument. It provides information
38
31
// about the request, including the http.Request object, the GET and POST params,
@@ -41,7 +34,7 @@ type Context struct {
41
34
Request * http.Request
42
35
Params map [string ]string
43
36
Server * Server
44
- ResponseWriter
37
+ http. ResponseWriter
45
38
}
46
39
47
40
// WriteString writes string data into the response object.
@@ -208,23 +201,6 @@ func (s *Server) addRoute(r string, method string, handler interface{}) {
208
201
}
209
202
}
210
203
211
- type responseWriter struct {
212
- http.ResponseWriter
213
- }
214
-
215
- // Close terminates the HTTP connection, and flushes all pending
216
- // response data.
217
- func (c * responseWriter ) Close () {
218
- rwc , buf , _ := c .ResponseWriter .(http.Hijacker ).Hijack ()
219
- if buf != nil {
220
- buf .Flush ()
221
- }
222
-
223
- if rwc != nil {
224
- rwc .Close ()
225
- }
226
- }
227
-
228
204
// ServeHTTP is the interface method for Go's http server package
229
205
func (s * Server ) ServeHTTP (c http.ResponseWriter , req * http.Request ) {
230
206
s .Process (c , req )
@@ -281,7 +257,7 @@ func requiresContext(handlerType reflect.Type) bool {
281
257
}
282
258
283
259
// the main route handler in web.go
284
- func (s * Server ) routeHandler (req * http.Request , w ResponseWriter ) {
260
+ func (s * Server ) routeHandler (req * http.Request , w http. ResponseWriter ) {
285
261
requestPath := req .URL .Path
286
262
ctx := Context {req , map [string ]string {}, s , w }
287
263
@@ -391,7 +367,7 @@ type ServerConfig struct {
391
367
RecoverPanic bool
392
368
}
393
369
394
- // Server represents a web.go server.
370
+ // Server represents a web.go server.
395
371
type Server struct {
396
372
Config * ServerConfig
397
373
routes []route
@@ -421,8 +397,7 @@ func (s *Server) initServer() {
421
397
422
398
// Process invokes the routing system for server s
423
399
func (s * Server ) Process (c http.ResponseWriter , req * http.Request ) {
424
- w := responseWriter {c }
425
- s .routeHandler (req , & w )
400
+ s .routeHandler (req , c )
426
401
}
427
402
428
403
// Run starts the web application and serves HTTP requests for s
0 commit comments