GithubHelp home page GithubHelp logo

restfulie's Introduction

Web site

Restfulie’s website can be found at http://restfulie.caelumobjects.com
From there you can see some videos and read the Restfulie from Scratch guide.

Quit pretending

CRUD through HTTP is a good step forward to using resources and becoming RESTful, another step further into it is to make use of hypermedia and semantic meaningful media types: this gem allows you to do it really fast.

You can read the article on using the web for real which gives an introduction to hypermedia/resources/services.

Why would I use restfulie?

  1. Easy —> writing hypermedia and semantic meaningful media type aware clients
  2. Small → it’s not a bloated solution with a huge list of APIs
  3. HATEOAS —> clients you are unaware of will not bother if you change
  4. HATEOAS —> consumed resources will not affect your software whenever they change their flow
  5. Adaptability —> clients are able to adapt to your changes

Simple server example

In the server side, all you need to do is notify inherited_resources which media types you are able to represent your resource:

	class OrdersController < ApplicationController
	  include Restfulie::Server::ActionController::Base

	  respond_to :atom, :html, :xml, :commerce, :opensearch

	  def index
	    respond_with @orders = Order.all
	  end

	  def show
	    respond_with @order = Order.find(params[:id])
	  end

	end

That’s it. Restfulie will take care of rendering a valid representation according to content negotiation. You can configure the rendering process through a custom tokamak view:

	collection(@orders) do |collection|
	  collection.values do |value|
		value.id = orders_url
	  end
	  
	  collection.link("create", orders_url)
	  collection.members
	end

You can go through an entire application by watching this video or downloading an example application.

Simple client example

The following example is a partial REST client implementation that navigates through some relations:

order = Restfulie.at('http://localhost:3000/orders/1').get!
order.items.each { |item| puts items }
receipt = order.payment.post! { :amount => 500 }
puts receipt.id

In order to create a full REST client, watch this video.

Full examples

You can view an entire application running Restfulie under spec/integration/order/server and spec/integration/order/client in this git repository.

You can also download a full example of a REST based agent and server using Restfulie, according to the Rest Architecture Maturity Model.

Documentation

Appart from the simple server and client examples provided here, you can find the following links useful:

Installing

For client side usage, execute:

gem install activesupport
gem install restfulie

For server side usage, execute:

gem install restfulie

Building the project

If you want to build the project and run its tests, remember to install all (client and server) required gem.
Bundler is required to easily manage dependencies

bundle install

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.