From f769dc7b006dd3d896729344a5f67fb74dc6786e Mon Sep 17 00:00:00 2001 From: tv Date: Sun, 5 Jan 2014 23:09:08 +0100 Subject: go: redirect with 302 --- go/README | 11 ++++++++++- go/index.js | 7 +++++-- 2 files changed, 15 insertions(+), 3 deletions(-) (limited to 'go') diff --git a/go/README b/go/README index 0f9de490..0434335a 100644 --- a/go/README +++ b/go/README @@ -7,7 +7,16 @@ go - minimalistic uri shortener npm install hiredis # run service - node . + PORT=1337 node . + +# add uri + curl -F uri=https://mywaytoolonguri http://localhost:1337 + + this will give you a relative shortened uri. + +# resolve uri + + curl http://localhost:1337/shortened-relative-uri # clear database diff --git a/go/index.js b/go/index.js index 723fb78a..470010a9 100644 --- a/go/index.js +++ b/go/index.js @@ -68,8 +68,11 @@ function retrieve (req, res) { return res.end('not found\r\n'); } - res.writeHead(200, { 'content-type': 'text/plain' }); - return res.end(reply + '\r\n'); + res.writeHead(302, { + 'content-type': 'text/plain', + 'location': reply, + }); + return res.end(); }); } -- cgit v1.2.3