1.3.0 • Published 9 years ago

resturlify v1.3.0

Weekly downloads
8
License
MIT
Repository
github
Last release
9 years ago

RestUrlify

Consistently Generate Rest URLs

Why?

I wrote this to help transition my team from an RPC-each-call-a-snowflake tendency to REST.

Use Anywhere

This library works in the client and on the server.

Install

bower install resturlify

Or

npm install resturlify

Examples

Constructor

var urlTools = new RestUrlify("http://www.web.com/api");

Simple

urlTools.buildUrl()

Returns: http://www.web.com/api

With Params

urlTools.buildUrl({ 
  resource: 'resource',
  query: {id : 1}
})

Returns: http://www.web.com/api/resource?id=1

Custom Methods

urlTools.buildUrl({
  resource: 'resource',
  id: 1,
  customMethod: 'approve'
})

Returns: http://www.web.com/api/resource/1/approve