###(Work in progress - adapted from sbrd.me)
-
The purpose of this application is really nothing special. I'm trying to teach myself how to build a very simple API (using Sinatra) which reads from and writes data to a file residing in the public folder. This example program will be used as a basis for a slightly larger project in which I'm going to attempt to build a speed dial directory management tool for Polycom Soundpoint IP telephones (which is something I really need for my current job).
-
I doubt this project will be of any real interest to anyone but myself, however if you have any comments, tips, tricks or best practices to offer I'm all ears.
- You will need to setup an rvm environment running ruby-2.0.0-p247.
- You will also need to create a gemset called
fio
-
note: make sure you remember to issue
rvm use ruby-2.0.0-p247@fio --create
from the command line. -
remember to create a .ruby-version and .ruby-gemset file:
.ruby-version:
ruby-2.0.0-p247
.ruby-gemset:
fio
-
- You will also need to create a gemset called
- Clone the Repo: Run
git clone [email protected]/medwards42/fio.git
- Install the dependencies
- Run
gem install bundler
- Run
bundle install
- Run
bundle exec rackup -s thin -p 8000
- Run
RACK_ENV=test bundle exec rake spec
-
This doc and APIs are a work in progress. The APIs signatures and responses should not be considered final in any form. See the section on versioning for details on currently supported versions.
-
All calls will use HTTP endpoints.
-
All requests are in text format and must include a valid URI string.
-
All responses will be in JSON format.
-
GET requests must include a url key in order for a redirect to be generated.
200 - OK
404 - Bad request - we return a custom message
500 - Server Error
While working for Songbird I learned (from folks much wiser than I) that it really is a good idea to include some type of health_check function within an application. It offers users an easy way to just check and see that your app is up and running. Also, since my background is more on the Systems Admin side I can tell you that it makes writing Nagios checks a whole lot nicer.
Example:
curl http://localhost:8000/health_check -v
Valid Response:
* Connected to localhost (127.0.0.1) port 8000 (#0)
> GET /health_check HTTP/1.1
> User-Agent: curl/7.24.0 (x86_64-apple-darwin12.0) libcurl/7.24.0 OpenSSL/0.9.8x zlib/1.2.5
> Host: localhost:8000
> Accept: */*
>
< HTTP/1.1 200 OK
< Content-Type: text/html;charset=utf-8
< Content-Length: 15
< X-XSS-Protection: 1; mode=block
< X-Content-Type-Options: nosniff
< X-Frame-Options: SAMEORIGIN
< Connection: keep-alive
< Server: thin 1.5.1 codename Straight Razor
<
* Connection #0 to host localhost left intact
All Systems Go!* Closing connection #0
"All Systems Go!" means exactly that. The health_check shows an API consumer that the service is online and responding to requests correctly.
-
Staging - http://
-
Production - http://
-
Development = http://localhost:8000/
This repo consists of one branch, currently it is:
- checkin
To push to each app you'll need to do the following:
git remote add origin [email protected]:medwards42/fio.git
git push origin checkin