diff --git a/sketching/curl.dms b/sketching/curl.dms index 1b0519b..7ab2e94 100644 --- a/sketching/curl.dms +++ b/sketching/curl.dms @@ -13,3 +13,16 @@ fn main = jsonClient() map || ( it.body.accessToken ) fold println () + +# Better: main which returns IO (a Callable?) automatically calls the IO +# Also, JsonClient can "login" using various methods, such as a Bearer token + +use std::http::{jsonClient, bearerToken} + +fn main = jsonClient( + baseUrl: 'http:/localhost:1234', + auth: bearerToken || ( post('/login', username: 'test', password: 'test') map || ( it.body.accessToken ) ) +) + get '/greeting' + map || ( it.body.greeting ) + fold println