lib/oleg: add comments

This commit is contained in:
Christine Dodrill 2015-02-06 20:30:46 -08:00
parent 546e4411f8
commit 62d78a2456
1 changed files with 16 additions and 10 deletions

View File

@ -1,11 +1,12 @@
config = require("lapis.config").get! config = require("lapis.config").get!
http = require "lapis.nginx.http" http = require "lapis.nginx.http"
request = (method, table, key, value=nil) -> request = (method, table, key, value=nil, headers={}) ->
oleg_res, code = http.simple { oleg_res, code = http.simple {
url: "http://#{config.oleg.host}:#{config.oleg.port}/#{table}/#{key}" url: "http://#{config.oleg.host}:#{config.oleg.port}/#{table}/#{key}"
method: method method: method
body: value body: value
headers: headers
} }
if code ~= 200 if code ~= 200
@ -18,13 +19,18 @@ request = (method, table, key, value=nil) ->
ret = {} ret = {}
ret.get = (table, key) -> ret.request = request
request "GET", table, key
ret.delete = (table, key) -> --- get gets a key from a table and returns the data and either nil or a error message
request "DELETE" ret.get = (tab, key) ->
request "GET", tab, key
ret.set = (table, key, value) -> --- delete deltes key from tab
request "POST", table, key, value ret.delete = (tab, key) ->
request "DELETE", tab, key
--- set sets key in tab to value
ret.set = (tab, key, value) ->
request "POST", tab, key, value
ret ret