From c8d12ce26e1847745077a187cccabf417f118732 Mon Sep 17 00:00:00 2001 From: Kaarle Ritvanen Date: Mon, 16 Sep 2013 10:56:21 +0300 Subject: protocol: change URL for transaction operations to /transaction --- dev-shell | 4 ++-- protocol.txt | 6 +++--- server.lua | 5 +++-- web/client.js | 8 +++++--- 4 files changed, 13 insertions(+), 10 deletions(-) diff --git a/dev-shell b/dev-shell index 920066b..7eba7ab 100755 --- a/dev-shell +++ b/dev-shell @@ -80,7 +80,7 @@ EOF PS1="$ACF_USER@acf2-dev-shell${ACF_TXN_ID:+($ACF_TXN_ID)}> " function start { - _acf_start_req / Transaction-ID TXN_ID -X POST + _acf_start_req /transaction Transaction-ID TXN_ID -X POST } function meta { @@ -115,7 +115,7 @@ EOF function commit { if [ "$ACF_TXN_ID" ]; then - if _acf_req / -X PUT; then + if _acf_req /transaction -X PUT; then echo Committed >&2 exit 1 fi diff --git a/protocol.txt b/protocol.txt index 523b474..bf00116 100644 --- a/protocol.txt +++ b/protocol.txt @@ -15,7 +15,7 @@ req: DELETE /login X-ACF-Auth-Token: Start transaction: -req: POST / +req: POST /transaction resp: txn ID (in header as X-ACF-Transaction-ID) - use X-ACF-Transaction-ID in the header of any subsequent request to process it in the transaction's context @@ -23,11 +23,11 @@ resp: txn ID (in header as X-ACF-Transaction-ID) start transaction request Commit transaction: -req: PUT / +req: PUT /transaction X-ACF-Transaction-ID: Abort transaction: -req: DELETE / +req: DELETE /transaction X-ACF-Transaction-ID: Get object: diff --git a/server.lua b/server.lua index 457e238..7168c0e 100644 --- a/server.lua +++ b/server.lua @@ -39,7 +39,8 @@ return function(env) ) end - if path == '/' and method == 'GET' then + if path == '/' then + if method ~= 'GET' then return wrap(405) end return wrap(301, {['Location']='/browser/'}) end @@ -219,7 +220,7 @@ return function(env) return res == nil and 205 or 200, nil, res end - if path == '/' then + if path == '/transaction' then if ({DELETE=true, PUT=true})[method] then if not txn_id then return 405 end if method == 'PUT' then parent_txn:commit() end diff --git a/web/client.js b/web/client.js index d0114ca..c856788 100644 --- a/web/client.js +++ b/web/client.js @@ -84,7 +84,7 @@ $(function() { } function abort() { - var def = request("/", {type: "DELETE"}); + var def = request("/transaction", {type: "DELETE"}); reset(); return def; } @@ -299,7 +299,7 @@ $(function() { if (txn) def.resolve(); - else request("/", {type: "POST"}) + else request("/transaction", {type: "POST"}) .done(function(data, status, xhr) { txn = xhr.getResponseHeader( "X-ACF-Transaction-ID" @@ -313,7 +313,9 @@ $(function() { commit: function() { var def = $.Deferred(); - request("/", {type: "PUT"}).done(function() { + request( + "/transaction", {type: "PUT"} + ).done(function() { reset(); def.resolve(); }).fail(function(xhr) { def.reject(xhr); }); -- cgit v1.2.3