completed first version of the Ajax API
This commit is contained in:
parent
27cacbd271
commit
7d3224183a
2 changed files with 5 additions and 8 deletions
|
|
@ -30,9 +30,3 @@ Goals
|
||||||
- Leverage Nim's macro system to produce a framework that allows
|
- Leverage Nim's macro system to produce a framework that allows
|
||||||
for the development of applications that are boilerplate free.
|
for the development of applications that are boilerplate free.
|
||||||
- Keep it small, keep it fast, keep it flexible.
|
- Keep it small, keep it fast, keep it flexible.
|
||||||
|
|
||||||
|
|
||||||
Todo
|
|
||||||
====
|
|
||||||
|
|
||||||
- Expose a nice API to do Ajax requests.
|
|
||||||
|
|
|
||||||
|
|
@ -31,11 +31,14 @@ proc ajax(meth, url: cstring; headers: openarray[(cstring, cstring)];
|
||||||
ajax.send(`data`);
|
ajax.send(`data`);
|
||||||
""".}
|
""".}
|
||||||
|
|
||||||
proc ajaxPut*(url: string; headers: openarray[(cstring, cstring)];
|
proc ajaxPut*(url: cstring; headers: openarray[(cstring, cstring)];
|
||||||
data: cstring;
|
data: cstring;
|
||||||
cont: proc (httpStatus: int, response: cstring)) =
|
cont: proc (httpStatus: int, response: cstring)) =
|
||||||
ajax("PUT", url, headers, data, cont)
|
ajax("PUT", url, headers, data, cont)
|
||||||
|
|
||||||
proc ajaxGet*(url: string; headers: openarray[(cstring, cstring)];
|
proc ajaxGet*(url: cstring; headers: openarray[(cstring, cstring)];
|
||||||
cont: proc (httpStatus: int, response: cstring)) =
|
cont: proc (httpStatus: int, response: cstring)) =
|
||||||
ajax("GET", url, headers, nil, cont)
|
ajax("GET", url, headers, nil, cont)
|
||||||
|
|
||||||
|
proc toJson*[T](data: T): cstring {.importc: "JSON.stringify".}
|
||||||
|
proc fromJson*[T](blob: cstring): T {.importc: "JSON.parse".}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue