Skip to content

Commit

Permalink
[lib/pdk] Fix formatting issues
Browse files Browse the repository at this point in the history
  • Loading branch information
titzer committed Oct 24, 2024
1 parent 5eb8f54 commit a8c18e8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 18 deletions.
19 changes: 9 additions & 10 deletions lib/pdk/Header.v3
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,23 @@
// Multiple values for a single key are not deduped.
class Header {
def map = Strings.newMap<string>();
var mapLen = 0;
var mapLen = 0;
var b: StringBuilder; // hack to work around no inline function closures:
var index = 0;

// hack to work around no inline function closures:
var b: StringBuilder;
var index = 0;
private def keyValueToJson(key: string, value: string) {
if (index < mapLen - 1) {
b.put2("\"%s\":\"%s\",", key, value);
} else {
b.put2("\"%s\":\"%s\"", key, value);
}
index++;
index++;
}

def toJson() -> string {
b = StringBuilder.new();
b.puts("{");
index = 0;
index = 0;
map.apply(keyValueToJson);
b.puts("}");
return b.toString();
Expand All @@ -37,9 +36,9 @@ class Header {
map[key] = b.toString();
}
false => {
map[key] = value;
mapLen++;
}
map[key] = value;
mapLen++;
}
}
}
}
}
16 changes: 8 additions & 8 deletions lib/pdk/Method.v3
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@
// Descriptions are from: https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods
enum Method {
// The GET method requests a representation of the specified resource. Requests using GET should only retrieve data.
GET
GET,
// The HEAD method asks for a response identical to a GET request, but without the response body.
HEAD
HEAD,
// The POST method submits an entity to the specified resource, often causing a change in state or side effects on the server.
POST
POST,
// The PUT method replaces all current representations of the target resource with the request payload.
PUT
PUT,
// The DELETE method deletes the specified resource.
DELETE
DELETE,
// The CONNECT method establishes a tunnel to the server identified by the target resource.
CONNECT
CONNECT,
// The OPTIONS method describes the communication options for the target resource.
OPTIONS
OPTIONS,
// The TRACE method performs a message loop-back test along the path to the target resource.
TRACE
TRACE,
// The PATCH method applies partial modifications to a resource.
PATCH
}

0 comments on commit a8c18e8

Please sign in to comment.