Skip to content
app.routes 990 B
Newer Older
theMackabu's avatar
theMackabu committed
index {
theMackabu's avatar
theMackabu committed
   text(":3\nwelcome to the root")
}

hello() {
   text("Hello World!")
}

theMackabu's avatar
theMackabu committed
example() {
theMackabu's avatar
theMackabu committed
   html(http::get("https://example.org").body)
theMackabu's avatar
theMackabu committed
}

example/json() {
   let res = http::get("https://httpbin.org/json");
theMackabu's avatar
theMackabu committed
   let body = #{ 
theMackabu's avatar
theMackabu committed
      response: res.json(),
theMackabu's avatar
theMackabu committed
      info: #{
         length: res.length,
         status: res.status,
         error: res.error,
         body: res.body,
theMackabu's avatar
theMackabu committed
      },
theMackabu's avatar
theMackabu committed
   };
   
   json(body)
}

example/post/bin() {
theMackabu's avatar
theMackabu committed
   let body = #{ 
      hello: "world",
      url: url,
   };
   
   json(http::post("https://httpbin.org/post", body).raw())
theMackabu's avatar
theMackabu committed
}
theMackabu's avatar
theMackabu committed

theMackabu's avatar
theMackabu committed
test.json() {
theMackabu's avatar
theMackabu committed
   let res = #{
       hello: "world",
       info: #{
         path: path,
         url: url,
         ver: ver,
         query: query,
       }
   };
   
   json(res)
}

test/loadfile() {
   let file = open_file("test.html");
   html(file.read_string())
}

theMackabu's avatar
theMackabu committed
// remove to test 404 route
theMackabu's avatar
theMackabu committed
* {
theMackabu's avatar
theMackabu committed
   text("this is a wildcard route\ncurrently on: " + path + "\n\n" + err)
theMackabu's avatar
theMackabu committed
}

404 {
   text("404 page\n\n" + err)