kenichi / angelo

Sinatra-like DSL for Reel that supports WebSockets and SSE
Other
303 stars 23 forks source link

Add ContentTypeHandlers #44

Closed edpaget closed 6 years ago

edpaget commented 9 years ago

Allow new content types to be declared with custom handling for response creation and validation.

Closes #22


I still need to add some tests for the content handler functionality. I figured I'd post this make sure you were okay with the design before I finished adding them.

tommay commented 9 years ago

This makes the ContentTypeHandlers global to all Angelo::Base subclasses rather than being per-subclass. My take on things was that everything should be per-subclass to allow multiple angelo servers in one application. Never mind that Reponder had a global content type, that was something that needed to be fixed IMO.

tommay commented 9 years ago

Here's a test for cross-subclass leakage:

https://gist.github.com/tommay/0cf5f805b2d8759eb6c2

edpaget commented 9 years ago

Thanks. I try to revise this to prevent leakage. I don't think it'll be too much of an issue to handle that all.