Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Echo response that implements http.Hijack #68

Closed
mschewe opened this issue May 18, 2015 · 6 comments
Closed

Echo response that implements http.Hijack #68

mschewe opened this issue May 18, 2015 · 6 comments
Assignees

Comments

@mschewe
Copy link

mschewe commented May 18, 2015

I could just copy that issue: go-martini/martini#45

It's almost the same problem. I am new to go and working on my first small project. I am now almost done and wanted to add websockets.

But I ran into this error websocket: response does not implement http.Hijacker.
I guess I could just rewrite some parts and use Martini or some other framework, but I really started to like Echo.

What do you think? Would it be possible to implement http.Hijack or would this be against the concept of Echo?

As in the Martini issue I would like to say: "please excuse me if this is just nonesense".

@vishr vishr self-assigned this May 18, 2015
@vishr
Copy link
Member

vishr commented May 18, 2015

Can you share the code?

@mschewe
Copy link
Author

mschewe commented May 18, 2015

I have created a minimal example that reproduces the problem: https://gist.github.com/mschewe/47b08668e6b81f3d4b4f

@vishr
Copy link
Member

vishr commented May 19, 2015

Please verify - #70

PS: I have a plan to add web socket to the API in future.

@vishr vishr closed this as completed May 19, 2015
@mschewe
Copy link
Author

mschewe commented May 19, 2015

As far as I can see it does now work perfectly. Thank you very much!

@vishr
Copy link
Member

vishr commented May 21, 2015

@mschewe FYI, I have added support for WebSocket in the latest version, here is a small example:

package main

import (
    "github.com/labstack/echo"
    "github.com/labstack/echo/middleware"
    "io"
)

func main() {
    e := echo.New()
    e.Use(middleware.Logger())
    e.WebSocket("/ws/:token", func(c *echo.Context) error {
        io.Copy(c.Socket(), c.Socket())
        return nil
    })
    e.Run(":1323")
}

You can also access path parameters from the context.

@mschewe
Copy link
Author

mschewe commented May 21, 2015

Great, this make Echo even more useful!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants