vigetlabs / gangway

A client-side API abstraction layer
MIT License
13 stars 1 forks source link

Paths should be relative #38

Closed nhunzaker closed 8 years ago

nhunzaker commented 8 years ago

This PR adds relative path calculation such that the following configuration:

var api = new Gangway({
    baseUrl: 'https://example.com/bar',
})

api.route({
    exceptionToRules: {
        path: '/deviant'
    }
})

Will send a request to https://example.com/deviant. Additionally:

var api = new Gangway({
    baseUrl: 'https://example.com',
})

api.namespace('users').route({
    read: {
        path: '{id}'
    }
})

Would produce a request to https://example.com/users/{id}.

This should be more intuitive, and allow for more flexibility in path handling.

cwmanning commented 8 years ago

:+1: nice tests

benjtinsley commented 8 years ago

:+1: