Standard library
HTTP
Ask the internet for something. She will either bring it back, or bring back a status that wants a hug.
including "stdlib/http.alana";
then newobj Http().
Every call returns a Response — that type comes with this library. You do not have to invite it separately. Manners.
Http
| Function | What she does | Parameters | Returns |
|---|---|---|---|
Get |
Sends a GET request to a URL | str url |
A Response |
Post |
Sends a POST request to a URL | str url, str body, str content type |
A Response |
including "stdlib/http.alana";
define Http http is newobj Http();
define Response got is call http.Get("https://postman-echo.com/get");
define Response posted is call http.Post("https://postman-echo.com/post", body, "application/json");
Response
The object you get back. Status, body, a header if you know its name.
No extra including. It arrived with HTTP, like a plus-one.
| Function | What she does | Parameters | Returns |
|---|---|---|---|
GetStatus |
Gives you the status of the response | None | num |
GetBody |
Gives you the body of the response | None | str |
GetHeader |
Gives you a header of the response | str header name |
str |
define Response answer is call http.Get(url);
showln call answer.GetStatus();
showln call answer.GetBody();
showln call answer.GetHeader("Content-Type");