Skip to content

Commit

Permalink
Add support for path in API endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
Ladislav Prskavec committed Feb 22, 2014
1 parent 41ecb77 commit 9df45c4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/execute-transaction.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,15 @@ executeTransaction = (transaction, callback) ->
splitHeader = header.split(':')
flatHeaders[splitHeader[0]] = splitHeader[1]

if parsedUrl['path'] == "/"
fullPath = request['uri']
else
fullPath = parsedUrl['path'] + request['uri']

options =
host: parsedUrl['hostname']
port: parsedUrl['port']
path: request['uri']
path: fullPath
method: request['method']
headers: flatHeaders

Expand Down
11 changes: 11 additions & 0 deletions test/unit/execute-transaction-test.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -200,3 +200,14 @@ describe 'executeTransaction(transaction, callback)', () ->
assert.notOk server.isDone()
done()

describe 'test api endpoint with path', () ->
beforeEach () ->
server = nock('http://localhost:3000/v2').
post('/machines', {"type":"bulldozer","name":"willy"}).
reply 202, "Accepted"

it 'shoould make request at server endpoint', (done) ->
executeTransaction transaction, () ->
assert.ok server.isDone()
done()

0 comments on commit 9df45c4

Please sign in to comment.