lib/oleg: add comments
This commit is contained in:
parent
546e4411f8
commit
62d78a2456
|
@ -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
|
||||||
|
|
Loading…
Reference in New Issue