FAQ
Hi,

Are there any tutorials explaining how to create an EventSource web handler in Go? I've seen a package on GitHub, but I'm looking for something simpler and with explanation. I don't quite understand how to keep the connection open while streaming messages (possibly forever).

--

Search Discussions

  • Leroy Campbell at Oct 4, 2012 at 8:46 pm
    I think I have something here:

    http://gist.github.com/3836281

    --
  • Anton Ageev at Oct 5, 2012 at 1:42 am
    Take a look at net/http.Hijacker interface:

    type Hijacker interface {
    // Hijack lets the caller take over the connection.
    // After a call to Hijack(), the HTTP server library
    // will not do anything else with the connection.
    // It becomes the caller's responsibility to manage
    // and close the connection.
    Hijack() (net.Conn, *bufio.ReadWriter, error)
    }

    http://golang.org/pkg/net/http/#Hijacker


    Hi,
    Are there any tutorials explaining how to create an EventSource web
    handler in Go? I've seen a package on GitHub, but I'm looking for something
    simpler and with explanation. I don't quite understand how to keep the
    connection open while streaming messages (possibly forever).
    --
  • Webmaster at Oct 6, 2012 at 4:18 pm
    Thanks for the tip on connection hijacking. I tried it out, but found it
    easier to just use the Flusher interface.
    On Thursday, October 4, 2012 9:42:16 PM UTC-4, Anton Ageev wrote:

    Take a look at net/http.Hijacker interface:

    type Hijacker interface {
    // Hijack lets the caller take over the connection.
    // After a call to Hijack(), the HTTP server library
    // will not do anything else with the connection.
    // It becomes the caller's responsibility to manage
    // and close the connection.
    Hijack() (net.Conn, *bufio.ReadWriter, error)
    }

    http://golang.org/pkg/net/http/#Hijacker


    Hi,
    Are there any tutorials explaining how to create an EventSource web
    handler in Go? I've seen a package on GitHub, but I'm looking for something
    simpler and with explanation. I don't quite understand how to keep the
    connection open while streaming messages (possibly forever).
    --
  • Webmaster at Oct 6, 2012 at 4:18 pm
    I've updated my gist (https://gist.github.com/3836281). I added message
    broadcasting. Could someone critique the code?
    On Thursday, October 4, 2012 2:08:21 PM UTC-4, Leroy Campbell wrote:

    Hi,

    Are there any tutorials explaining how to create an EventSource web
    handler in Go? I've seen a package on GitHub, but I'm looking for something
    simpler and with explanation. I don't quite understand how to keep the
    connection open while streaming messages (possibly forever).
    --

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedOct 4, '12 at 6:08p
activeOct 6, '12 at 4:18p
posts5
users3
websitegolang.org

People

Translate

site design / logo © 2022 Grokbase