Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion content_type.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ fn parse_content_type(s : StringView) -> ContentType? {
}
}

Some({ media_type, subtype, params })
Some({ media_type, subtype, params, })
}

///|
Expand Down
8 changes: 4 additions & 4 deletions cookie.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,12 @@ pub fn parse_cookie(cookie : StringView) -> Map[String, CookieItem] {
let value = dequote(value).to_owned()
if last_cookie_item is Some((name, item)) {
if key =~ re"^(?i:path)$" {
let new_item = { ..item, path: Some(value) }
let new_item = { ..item, path: Some(value), }
res.set(name, new_item)
last_cookie_item = Some((name, new_item))
return
} else if key =~ re"^(?i:domain)$" {
let new_item = { ..item, domain: Some(value) }
let new_item = { ..item, domain: Some(value), }
res.set(name, new_item)
last_cookie_item = Some((name, new_item))
return
Expand All @@ -85,12 +85,12 @@ pub fn parse_cookie(cookie : StringView) -> Map[String, CookieItem] {
last_cookie_item = Some((name, new_item))
return
} else if key =~ re"^(?i:secure)$" {
let new_item = { ..item, secure: Some(true) }
let new_item = { ..item, secure: Some(true), }
res.set(name, new_item)
last_cookie_item = Some((name, new_item))
return
} else if key =~ re"^(?i:httponly)$" {
let new_item = { ..item, http_only: Some(true) }
let new_item = { ..item, http_only: Some(true), }
res.set(name, new_item)
last_cookie_item = Some((name, new_item))
return
Expand Down
2 changes: 1 addition & 1 deletion dispatch.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ pub async fn dispatch_http(
_ => ({}, handle_not_found())
}
let event = {
req: { http_method, url: path, query, raw_body, headers },
req: { http_method, url: path, query, raw_body, headers, },
res: HttpResponse::new(OK),
params,
}
Expand Down
2 changes: 1 addition & 1 deletion index.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ pub impl Show for CookieItem with fn output(self, logger) -> Unit {

///|
pub impl Show for CookieItem with fn to_string(self : CookieItem) -> String {
let buf = StringBuilder::new()
let buf = StringBuilder()
Show::output(self, buf)
buf.to_string()
}
Expand Down
2 changes: 1 addition & 1 deletion internal/header/header.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ pub fn sanitize_header_value(s : String) -> String {
if !s.contains("\r") && !s.contains("\n") {
return s
}
let buf = StringBuilder::new()
let buf = StringBuilder()
for c in s {
match c {
'\r' | '\n' => ()
Expand Down
4 changes: 2 additions & 2 deletions middleware.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ priv struct MiddlewareTrieNode {

///|
fn new_middleware_trie_node() -> MiddlewareTrieNode {
{ middlewares: [], children: {} }
{ middlewares: [], children: {}, }
}

///|
Expand Down Expand Up @@ -53,7 +53,7 @@ fn MiddlewareTrieNode::insert_middleware(
}
}
}
node.middlewares.push({ order, middleware })
node.middlewares.push({ order, middleware, })
}

///|
Expand Down
2 changes: 1 addition & 1 deletion mocket.js.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ pub fn __ws_emit_js_port(
_ => ()
}
}
let peer = WebSocketPeer::{ connection_id, subscribed_channels: [] }
let peer = WebSocketPeer::{ connection_id, subscribed_channels: [], }
dispatch_ws_event(handler, peer, event_type, payload)
}

Expand Down
4 changes: 2 additions & 2 deletions mocket.native.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ priv struct WebSocketOutboundQueue {

///|
fn WebSocketOutboundQueue::new() -> WebSocketOutboundQueue {
{ frames: [], draining: false, closed: false }
{ frames: [], draining: false, closed: false, }
}

///|
Expand Down Expand Up @@ -496,7 +496,7 @@ async fn handle_websocket_request(
let connection_id = next_ws_connection_id(port)
let outbound = register_native_ws_connection(connection_id, ws)
defer outbound.close()
let peer = WebSocketPeer::{ connection_id, subscribed_channels: [] }
let peer = WebSocketPeer::{ connection_id, subscribed_channels: [], }
handler(Open(peer))
try {
for ;; {
Expand Down
14 changes: 9 additions & 5 deletions path_match.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ priv struct DynamicRouteMatch {

///|
fn new_dynamic_route_trie_node() -> DynamicRouteTrieNode {
{ handler_entry: None, children: {}, edges: [] }
{ handler_entry: None, children: {}, edges: [], }
}

///|
Expand Down Expand Up @@ -249,7 +249,7 @@ fn DynamicRouteTrieNode::insert(
while i < parts.length() {
let part = parts[i]
if part == "**" {
node.edges.push(DeepWildcard({ order, handler }))
node.edges.push(DeepWildcard({ order, handler, }))
return
} else if part == "*" {
node = match node.wildcard_child() {
Expand Down Expand Up @@ -285,7 +285,7 @@ fn DynamicRouteTrieNode::insert(
i = i + 1
}
match node.handler_entry {
None => node.handler_entry = Some({ order, handler })
None => node.handler_entry = Some({ order, handler, })
Some(_) => ignore(())
}
}
Expand All @@ -300,7 +300,7 @@ fn DynamicRouteTrieNode::find(
let mut found = if path_idx >= path_parts.length() {
match self.handler_entry {
Some(entry) =>
Some({ order: entry.order, handler: entry.handler, params })
Some({ order: entry.order, handler: entry.handler, params, })
None => None
}
} else {
Expand Down Expand Up @@ -340,7 +340,11 @@ fn DynamicRouteTrieNode::find(
dynamic_route_remaining_path(path_parts, path_idx),
)
}
Some({ order: entry.order, handler: entry.handler, params: next_params })
Some({
order: entry.order,
handler: entry.handler,
params: next_params,
})
}
}
found = better_dynamic_route_match(found, candidate)
Expand Down
2 changes: 1 addition & 1 deletion static.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pub fn StaticAssetMeta::new(
size? : Int64,
encoding? : String,
) -> Self {
{ asset_type, etag, mtime, path, size, encoding }
{ asset_type, etag, mtime, path, size, encoding, }
}

///|
Expand Down
2 changes: 1 addition & 1 deletion static_file/internal/nativefs/nativefs_native.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub async fn stat_regular_file(path : String) -> FileStat? {
let size = file.size()
let (mtime, _) = file.mtime()
file.close()
Some({ size, mtime })
Some({ size, mtime, })
}

///|
Expand Down
2 changes: 1 addition & 1 deletion static_file/provider_native.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pub impl ServeStaticProvider for StaticFileProvider with fn get_meta(
let stat = @nativefs.stat_regular_file(full)
match stat {
None => None
Some({ size, mtime }) => {
Some({ size, mtime, }) => {
let asset_type = match file_extension(id.to_owned()) {
Some(ext) => self.get_type(ext)
None => None
Expand Down
2 changes: 1 addition & 1 deletion static_file/static_file.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pub fn new(
fallthrough? : Bool = false,
index_names? : Array[String] = default_index_names,
) -> StaticFileProvider {
{ path, fallthrough, index_names }
{ path, fallthrough, index_names, }
}

///|
Expand Down
2 changes: 1 addition & 1 deletion static_file/static_file_blackbox_test.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ fn Fixture::create(tag : String) -> Fixture raise {
@fs.write_string_to_file("\{root}/sub/index.html", "sub index")
// Outside the served root: must never be reachable through the mount.
@fs.write_string_to_file("\{base}/secret.txt", "outside root")
{ base, root }
{ base, root, }
}

///|
Expand Down
8 changes: 7 additions & 1 deletion static_wbtest.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,13 @@ fn MemProvider::new(
fallthrough? : Bool = false,
index_names? : Array[String] = ["index.html"],
) -> MemProvider {
{ files, mime: { "txt": "text/plain" }, fallthrough, index_names, probed: [] }
{
files,
mime: { "txt": "text/plain" },
fallthrough,
index_names,
probed: [],
}
}

///|
Expand Down
12 changes: 8 additions & 4 deletions uri/uri.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ fn parse_port(source : BytesView, authority : Authority) -> BytesView {

///|
fn parse_authority(source : BytesView, uri : Uri) -> BytesView raise ParseError {
let authority = Authority::{ userinfo: None, host: RegName(b""), port: None }
let authority = Authority::{ userinfo: None, host: RegName(b""), port: None, }
uri.authority = Some(authority)

// Try to parse userinfo first
Expand Down Expand Up @@ -545,7 +545,7 @@ test "RFC 3986 URI Reference Parsing" {
@test.assert_eq(uri.scheme, Some(b"http"))
assert_true(
uri.authority ==
Some({ userinfo: None, host: RegName(b"example.com"), port: None }),
Some({ userinfo: None, host: RegName(b"example.com"), port: None, }),
)
@test.assert_eq(uri.path, [b"path", b"to", b"resource"])
@test.assert_eq(uri.query, Some(b"query=parameter"))
Expand Down Expand Up @@ -590,7 +590,11 @@ test "RFC 3986 IPv6 Literal" {
@test.assert_eq(uri.scheme, Some(b"http"))
assert_true(
uri.authority ==
Some({ userinfo: None, host: IPv6Address(b"2001:db8::1"), port: Some(8080) }),
Some({
userinfo: None,
host: IPv6Address(b"2001:db8::1"),
port: Some(8080),
}),
)
@test.assert_eq(uri.path, [])
}
Expand Down Expand Up @@ -740,7 +744,7 @@ test "RFC 3986 Absolute URI Parsing" {
@test.assert_eq(uri.scheme, Some(b"http"))
assert_true(
uri.authority ==
Some({ userinfo: None, host: RegName(b"example.com"), port: None }),
Some({ userinfo: None, host: RegName(b"example.com"), port: None, }),
)
@test.assert_eq(uri.path, [b"path", b"to", b"resource"])
@test.assert_eq(uri.query, Some(b"query=parameter"))
Expand Down
10 changes: 5 additions & 5 deletions utils.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ fn parse_kv(part : BytesView, map : Map[String, String]) -> Unit {

///|
pub fn escape_html(s : String) -> String {
let buf = StringBuilder::new()
let buf = StringBuilder()
for c in s {
match c {
'&' => buf.write_string("&amp;")
Expand Down Expand Up @@ -154,7 +154,7 @@ fn is_unreserved(b : Byte) -> Bool {
///|
pub fn url_encode(s : String) -> String {
let bytes = @utf8.encode(s)
let buf = StringBuilder::new()
let buf = StringBuilder()
for i in 0..<bytes.length() {
let b = bytes[i]
if is_unreserved(b) {
Expand Down Expand Up @@ -182,7 +182,7 @@ pub fn url_encode(s : String) -> String {

///|
pub fn form_encode(map : Map[String, String]) -> String {
let buf = StringBuilder::new()
let buf = StringBuilder()
let mut first = true
map.each(fn(k, v) {
if !first {
Expand Down Expand Up @@ -329,7 +329,7 @@ fn parse_multipart_part(
}
}
if name != "" {
res.set(name, { filename, content_type, data: body_bytes })
res.set(name, { filename, content_type, data: body_bytes, })
}
}

Expand All @@ -338,7 +338,7 @@ pub fn encode_multipart(
m : Map[String, MultipartFormValue],
boundary : String,
) -> String {
let sb = StringBuilder::new()
let sb = StringBuilder()
m.each(fn(name, v) {
sb.write_string("--" + boundary + "\r\n")
sb.write_string("Content-Disposition: form-data; name=\"" + name + "\"")
Expand Down