Comments (4)
Hi, first of all thanks for trying out the code and the bug report :-)
To answer your last question first, I haven't used this package with any other middleware systems. It looks like the Flush() here is causing your problem:
https://github.com/donovanhide/eventsource/blob/master/server.go#L78
which invokes:
which writes the header :-) This is needed for eventsource streams which don't start broadcasting immediately (unlike your example code) so that the client can inspect the headers first and know that the response is in fact an event stream and the carry on waiting for some events to come later.
So, to solve your actual problem, you could avoid n.Run(...)
and set up your own http.ListenAndServe()
which has a router that sends some request paths to your SSE
server and others to a Negroni set of handlers. I guess the question is whether you actually need some middleware functionality for your eventsource handler? If so, I guess this test needs beefing up as there may be some issue within negroni itself when handling flushes:
Let me know if you need more help!
from eventsource.
This looks like the easiest way to solve what you are doing:
https://github.com/codegangsta/negroni#route-specific-middleware
from eventsource.
Thanks @donovanhide !
I took some time to try and reproduce the bug but went short on going further.
Anyway, yes, the eventsource stream could benefit from the existing middlewares such as permissions, logger and so on.
I'll keep you in touch ;)
from eventsource.
Actually, there was a simple fix :-) See if it works for you now!
from eventsource.
Related Issues (13)
- Doesn't work with redirects. HOT 4
- Logging of messages to stdout HOT 7
- override the http client settings HOT 2
- Contributing preferences HOT 1
- Authenticate a request HOT 1
- Client will hang there if the server side crashed after the connection has already been established. HOT 2
- After call stream.Close(), panic: send on closed channel HOT 1
- server disconnect causes stream to spew out continuous errors HOT 8
- Make max backoff duration configurable
- CloseNotify() is deprecated HOT 1
- Close() for subscriptions. HOT 10
- eventsource stream does not handle "101:Switching Protocols" HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from eventsource.