https://github.com/torokmark/response_code
Response Code in readable way.
https://github.com/torokmark/response_code
http response-code status-codes
Last synced: 3 months ago
JSON representation
Response Code in readable way.
- Host: GitHub
- URL: https://github.com/torokmark/response_code
- Owner: torokmark
- License: mit
- Created: 2018-05-02T09:47:25.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2020-05-31T14:23:04.000Z (about 5 years ago)
- Last Synced: 2025-04-10T18:12:23.356Z (3 months ago)
- Topics: http, response-code, status-codes
- Language: Ruby
- Size: 21.5 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ResponseCode
[](https://travis-ci.org/torokmark/response_code)
[](https://badge.fury.io/rb/response_code)Who knows which response code represents the partial content? Or what code belongs to the error that says the request uri too long? Do you know the status code of the teapot?
ResponseCode is a tiny tool intended to give a handy way of handling response status codes with text instead of numbers.
### Install
```ruby
gem install response_code
```or
```ruby
gem 'response_code'
```### Usage
```ruby
require 'response_code'puts ResponseCode.ok
# => 200
```Using sinatra
```ruby
#!/usr/bin/env rubyrequire 'sinatra'
require 'response_code'get('/') {
status ResponseCode.im_a_teapot
'I\'m a teapot!'
}
```Executing `curl -i localhost:4567`
```
HTTP/1.1 418
Content-Type: text/html;charset=utf-8
Content-Length: 13
X-Xss-Protection: 1; mode=block
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
Server: WEBrick/1.4.2 (Ruby/2.5.0/2017-12-25)
Date: Thu, 03 May 2018 18:24:12 GMT
Connection: Keep-AliveI'm a teapot!
```