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

Allow status to be specified with symbols #968

Merged
merged 2 commits into from May 9, 2016

Conversation

Projects
None yet
4 participants
@tobiashm
Contributor

tobiashm commented Feb 3, 2015

Let the status helper accept symbols representing HTTP status codes, by looking up the numeric status code in Rack::Utils

This allows you to e.g. specify status :accepted instead of status 202, so readers of your code doesn't have to remember less used status codes.

Allow status to be specified with symbols
Let the `status` helper accept symbols representing HTTP status codes, by looking up the numeric status code in `Rack::Utils`

This allows you to e.g. specify `status :accepted` instead of `status 202`, so readers of your code doesn't have to remember less used status codes.
@kgrz

This comment has been minimized.

Show comment
Hide comment
@kgrz

kgrz Feb 5, 2015

Member

👍

Just one nitpick: any reason not to use the status_code method that's provided in the Rack::Utils module? It seems to default to 500 error if the symbol provided is not present in the hash.

Member

kgrz commented Feb 5, 2015

👍

Just one nitpick: any reason not to use the status_code method that's provided in the Rack::Utils module? It seems to default to 500 error if the symbol provided is not present in the hash.

@zzak zzak added this to the 1.5.0 milestone Feb 6, 2015

@zzak zzak added the feature label Feb 6, 2015

@tobiashm

This comment has been minimized.

Show comment
Hide comment
@tobiashm

tobiashm Feb 7, 2015

Contributor

@kgrz No, that looks even better. Will update PR.

Contributor

tobiashm commented Feb 7, 2015

@kgrz No, that looks even better. Will update PR.

@zzak zzak modified the milestones: 2.0.0, 1.5.0 Jan 31, 2016

@zzak zzak merged commit e25edc8 into sinatra:master May 9, 2016

1 check passed

continuous-integration/travis-ci The Travis CI build passed
Details
@zzak

This comment has been minimized.

Show comment
Hide comment
@zzak

zzak May 9, 2016

Member

@tobiashm LGTM, thank you!

Member

zzak commented May 9, 2016

@tobiashm LGTM, thank you!

@tobiashm tobiashm deleted the tobiashm:patch-1 branch May 10, 2016

@iainbeeston

This comment has been minimized.

Show comment
Hide comment
@iainbeeston

iainbeeston Oct 28, 2016

Contributor

Is there any way to extend this to the return values of route blocks as well? It'd be great to be able to do something like return [:ok, 'Looks good to me']. I've had a brief attempt at this (by pulling the changes from this PR down into Response#status=) but that didn't work. I'm happy to write a patch if anyone can suggest the best place to make the change.

Contributor

iainbeeston commented Oct 28, 2016

Is there any way to extend this to the return values of route blocks as well? It'd be great to be able to do something like return [:ok, 'Looks good to me']. I've had a brief attempt at this (by pulling the changes from this PR down into Response#status=) but that didn't work. I'm happy to write a patch if anyone can suggest the best place to make the change.

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