GithubHelp home page GithubHelp logo

leo424y / grape-on-rack Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ruby-grape/grape-on-rack

0.0 3.0 0.0 187 KB

A demo Grape API mounted on RACK.

License: MIT License

Ruby 94.61% HTML 4.02% JavaScript 1.37%

grape-on-rack's Introduction

Grape API on Rack

Build Status Dependency Status Code Climate

A Grape API mounted on Rack.

  • ping: a hello world example that returns a JSON document
  • post_put: a simple POST and PUT example
  • post_json: an example that shows a POST of JSON data
  • get_json: an example that pre-processes params sent as JSON data
  • rescue_from: an example of rescue_from that wraps all exceptions in an HTTP error code 500
  • path_versioning: an example that uses path-based versioning
  • header_versioning: an example that uses vendor header-based versioning
  • wrap_response: a middleware that wraps all responses and always returns HTTP code 200
  • content_type: an example that overrides the default Content-Type or returns data in both JSON and XML formats
  • upload_file: an example that demonstrates a file upload and download
  • entites: an example of using grape-entity

See

There's a deployed grape-on-rack on Heroku.

Run

$ bundle install
$ rackup

Loading NewRelic in developer mode ...
[2013-06-20 08:57:58] INFO  WEBrick 1.3.1
[2013-06-20 08:57:58] INFO  ruby 1.9.3 (2013-02-06) [x86_64-darwin11.4.2]
[2013-06-20 08:57:58] INFO  WEBrick::HTTPServer#start: pid=247 port=9292

Hello World

Navigate to http://localhost:9292/api/ping with a browser or use curl.

$ curl http://localhost:9292/api/ping

{"ping":"pong"}

Get Plain Text

$ curl http://localhost:9292/api/plain_text

A red brown fox jumped over the road.

Upload a File

$ curl -X POST -i -F image_file=@spec/fixtures/grape_logo.png http://localhost:9292/api/avatar

{"filename":"grape_logo.png","size":4272}

Upload and Download a File

$ curl -X POST -i -F file=@spec/fixtures/grape_logo.png http://localhost:9292/api/download.png
$ curl -X POST -i -F file=@api/ping.rb http://localhost:9292/api/download.rb

List Routes

rake routes

Explore the API

Explore the API using Swagger UI. Run the application and point the explorer to http://localhost:9292/api/swagger_doc or http://grape-on-rack.herokuapp.com/api/swagger_doc.

New Relic

The application is setup with NewRelic w/ Developer Mode. Navigate to http://localhost:9292/newrelic after making some API calls.

grape-on-rack's People

Contributors

dblock avatar hayesgm avatar rjayroach avatar humzashah avatar wprater avatar defp avatar

Watchers

James Cloos avatar Fly Chang avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.