From a88750d2b3f788c18f264a0f771ced024b4e1b42 Mon Sep 17 00:00:00 2001 From: astaxie Date: Tue, 10 Sep 2013 17:56:06 +0800 Subject: [PATCH] support websocket --- router.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/router.go b/router.go index 4099d5c7..eee29f1c 100644 --- a/router.go +++ b/router.go @@ -258,6 +258,12 @@ func (p *ControllerRegistor) ServeHTTP(rw http.ResponseWriter, r *http.Request) Output: beecontext.NewOutput(w), } context.Output.Context = context + + if context.Input.IsWebsocket() { + context.ResponseWriter = rw + context.Output = beecontext.NewOutput(rw) + } + var runrouter *controllerInfo var findrouter bool @@ -516,7 +522,7 @@ func (p *ControllerRegistor) ServeHTTP(rw http.ResponseWriter, r *http.Request) panic("gotofunc is exists:" + gotofunc) } } - if !w.started { + if !w.started && !context.Input.IsWebsocket() { if AutoRender { method = vc.MethodByName("Render") method.Call(in) @@ -600,7 +606,7 @@ func (p *ControllerRegistor) ServeHTTP(rw http.ResponseWriter, r *http.Request) method.Call(in) } } - if !w.started { + if !w.started && !context.Input.IsWebsocket() { if AutoRender { method = vc.MethodByName("Render") method.Call(in)