diff --git a/examples/simpleDELETE/simpleDELETE.jule b/examples/simpleDELETE/simpleDELETE.jule index accb3fd..9d61502 100644 --- a/examples/simpleDELETE/simpleDELETE.jule +++ b/examples/simpleDELETE/simpleDELETE.jule @@ -23,6 +23,6 @@ fn main() { fn handleStatus(code: status::StatusCode)! { if !status::IsSuccess(code) { - error(code) + throw code } } \ No newline at end of file diff --git a/examples/simpleDownload/simpleDownload.jule b/examples/simpleDownload/simpleDownload.jule index f2fd45d..4391a31 100644 --- a/examples/simpleDownload/simpleDownload.jule +++ b/examples/simpleDownload/simpleDownload.jule @@ -7,7 +7,7 @@ use "example/snapbox" fn main() { - snapbox::Download("https://httpbin.org/get", "examples/bin/output.txt") else { + snapbox::Download("https://httpbin.org/get", "examples/output.txt") else { println(error) } } \ No newline at end of file diff --git a/examples/simpleGET/simpleGET.jule b/examples/simpleGET/simpleGET.jule index 333543c..2b198b6 100644 --- a/examples/simpleGET/simpleGET.jule +++ b/examples/simpleGET/simpleGET.jule @@ -23,6 +23,6 @@ fn main() { fn handleStatus(code: status::StatusCode)! { if !status::IsSuccess(code) { - error(code) + throw code } } \ No newline at end of file diff --git a/examples/simplePOST/simplePOST.jule b/examples/simplePOST/simplePOST.jule index f657b18..352f513 100644 --- a/examples/simplePOST/simplePOST.jule +++ b/examples/simplePOST/simplePOST.jule @@ -12,7 +12,7 @@ const DATA = "Hello, World!" fn main() { let headerMap: header::HeaderMap = { - header::ACCEPT: "application/json", + header::ACCEPT: "application/json", header::CONTENT_TYPE: "text/plain", } @@ -26,6 +26,6 @@ fn main() { fn handleStatus(code: status::StatusCode)! { if !status::IsSuccess(code) { - error(code) + throw code } } \ No newline at end of file diff --git a/examples/simplePUT/simplePUT.jule b/examples/simplePUT/simplePUT.jule index 8ee8d66..7c78146 100644 --- a/examples/simplePUT/simplePUT.jule +++ b/examples/simplePUT/simplePUT.jule @@ -12,7 +12,7 @@ const DATA = "Puttin' on the Ritz..." fn main() { let headerMap: header::HeaderMap = { - header::ACCEPT: "application/json", + header::ACCEPT: "application/json", header::CONTENT_TYPE: "text/plain", } @@ -26,6 +26,6 @@ fn main() { fn handleStatus(code: status::StatusCode)! { if !status::IsSuccess(code) { - error(code) + throw code } } \ No newline at end of file diff --git a/header/_test.jule b/header/_test.jule index b435399..8982e62 100644 --- a/header/_test.jule +++ b/header/_test.jule @@ -12,7 +12,7 @@ use "std/testing" #test fn slicing(t: &testing::T) { let headerMap: HeaderMap = { - ACCEPT: "application/json", + ACCEPT: "application/json", USER_AGENT: "snapbox", } diff --git a/snapbox.jule b/snapbox.jule index bf6f02f..2bcaf42 100644 --- a/snapbox.jule +++ b/snapbox.jule @@ -11,22 +11,22 @@ BSD 3-Clause License use "snapbox/header" use "snapbox/status" -cpp use "snapbox/internal/curlwrapper.hpp" +extern use "snapbox/internal/curlwrapper.hpp" #typedef -cpp struct Response { +extern struct Response { body: str status: status::StatusCode } /* args: url, headers, method */ -cpp fn request(str, []str, int): cpp.Response +extern fn request(str, []str, int): extern.Response /* args: url, data, headers, method */ -cpp fn post(str, str, []str, int): cpp.Response +extern fn post(str, str, []str, int): extern.Response /* args: url, path */ -cpp fn download(str, str): bool +extern fn download(str, str): bool // Request structure for non-data requests. struct Request { @@ -37,9 +37,9 @@ struct Request { impl Request { // Executes the request and returns the response. - fn Send(*self): cpp.Response { + fn Send(*self): extern.Response { headers := header::Slice(self.headers) - ret cpp.request(self.url, headers, self.method) + ret extern.request(self.url, headers, self.method) } // Sets headers for the request. @@ -59,9 +59,9 @@ struct DataRequest { impl DataRequest { // Executes the request and returns the response. - fn Send(*self): cpp.Response { + fn Send(*self): extern.Response { headers := header::Slice(self.headers) - ret cpp.post(self.url, self.data, headers, self.method) + ret extern.post(self.url, self.data, headers, self.method) } // Sets headers for the request. @@ -80,7 +80,7 @@ impl DataRequest { // Builds a GET request object. fn GET(url: str): Request { ret Request{ - url: url, + url: url, method: 0, } } @@ -88,7 +88,7 @@ fn GET(url: str): Request { // Builds a HEAD request object. fn HEAD(url: str): Request { ret Request{ - url: url, + url: url, method: 1, } } @@ -96,7 +96,7 @@ fn HEAD(url: str): Request { // Builds a POST request object. fn POST(url: str): DataRequest { ret DataRequest{ - url: url, + url: url, method: 0, } } @@ -104,7 +104,7 @@ fn POST(url: str): DataRequest { // Builds a PUT request object. fn PUT(url: str): DataRequest { ret DataRequest{ - url: url, + url: url, method: 1, } } @@ -112,14 +112,14 @@ fn PUT(url: str): DataRequest { // Builds a DELETE request object. fn DELETE(url: str): DataRequest { ret DataRequest{ - url: url, + url: url, method: 2, } } // Uses the internal C++ function to download a file from the given URL and save it to the given path. fn Download(url: str, path: str)! { - response := cpp.download(url, path) + response := extern.download(url, path) if !response { panic("Download failed") }