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

Allow status to be specified with symbols #968

Merged
merged 2 commits into from May 9, 2016
Merged

Conversation

tobiashm
Copy link
Contributor

@tobiashm 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.

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
Copy link
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
Copy link
Contributor Author

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
@zzak
Copy link
Member

zzak commented May 9, 2016

@tobiashm LGTM, thank you!

@tobiashm tobiashm deleted the patch-1 branch May 10, 2016 12:19
@iainbeeston
Copy link
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.

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.

None yet

4 participants