moonbitstack/moonapi/ctx does not have a README file
pub struct BackgroundTasks {
// private fields
}pub(all) struct Context {
request : Request
params : Map[String, String]
scope : HttpScope
background : BackgroundTasks
}test {
let request : @moonasgi.Request = {
http_method: "POST",
path: "/login",
query_string: b"",
headers: [],
body: b"{\"user\":\"ada\"}",
}
assert_eq(@ctx.Context::new(request).body_json(), Some({ "user": "ada" }))
assert_eq(
@ctx.Context::new({ ..request, body: b"not json", }).body_json(),
None,
)
}test {
let request : @moonasgi.Request = {
http_method: "GET",
path: "/users/42",
query_string: b"",
headers: [],
body: b"",
}
let ctx = @ctx.Context::new(request, params=Map([("id", "42")]))
assert_eq(ctx.param("id"), Some("42"))
assert_eq(ctx.param("name"), None)
}test {
let request : @moonasgi.Request = {
http_method: "GET",
path: "/search",
query_string: b"q=cat%20dog&q=fish",
headers: [],
body: b"",
}
let ctx = @ctx.Context::new(request)
assert_eq(ctx.query("q"), Some("cat dog"))
assert_eq(ctx.query_all("q"), ["cat dog", "fish"])
}pub(all) struct HttpBasicCredentials {
username : String
password : String
}fn OAuth2PasswordRequestForm::not_equal(x : OAuth2PasswordRequestForm, y : OAuth2PasswordRequestForm) -> Bool