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

nsqadmin: format responses #612

Merged
merged 2 commits into from
Jul 31, 2015
Merged

Conversation

jehiah
Copy link
Member

@jehiah jehiah commented Jul 31, 2015

This fixes a regresion from #610 where some responses from nsqadmin were not handled properly (notably errors and /static/... assets)

RFR @mreiferson

@jehiah jehiah added the bug label Jul 31, 2015
router.Handle("POST", "/delete_channel", http_api.Decorate(s.deleteChannelHandler, log, http_api.PlainText))
router.Handle("POST", "/pause_channel", http_api.Decorate(s.pauseChannelHandler, log, http_api.PlainText))
router.Handle("POST", "/unpause_channel", http_api.Decorate(s.pauseChannelHandler, log, http_api.PlainText))
router.Handle("POST", "/create_topic_channel", http_api.Decorate(s.createTopicChannelHandler, log, http_api.PlainText))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe it makes sense to use a little function-local helper function at this point, maybe something like

func router_reg(method, path string, handler http.Handler) {
    router.Handle(method, path, http_api.Decorate(handler, log), http_api.PlainText)
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not a bad idea but also not necessary

@mreiferson
Copy link
Member

whoooops, thanks 😁

mreiferson added a commit that referenced this pull request Jul 31, 2015
@mreiferson mreiferson merged commit fd62604 into nsqio:master Jul 31, 2015
@mreiferson mreiferson deleted the nsqadmin_response_612 branch July 31, 2015 20:46
router.Handle("GET", "/node/:node", http_api.Decorate(s.nodeHandler, log, http_api.PlainText))
router.Handle("GET", "/topic/:topic", http_api.Decorate(s.topicHandler, log, http_api.PlainText))
router.Handle("GET", "/topic/:topic/:channel", http_api.Decorate(s.channelHandler, log, http_api.PlainText))
router.Handle("GET", "/static/*asset", http_api.Decorate(s.embeddedAssetHandler, log, http_api.PlainText))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Meh, I should have dug into this a bit more - only this static route needed the output formatter, all the other template based endpoints write directly to the http.ResponseWriter.

It's fine though, it won't cause any problems and it's all going away in #323

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think they still needed it for early error returns where the handler didn't write a response?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aha!

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

Successfully merging this pull request may close these issues.

3 participants