Formatting & some cleanup

cron
Jef Roosens 2022-02-20 13:10:48 +01:00
parent fbba66caa5
commit 5515e2dca5
Signed by untrusted user: Jef Roosens
GPG Key ID: 955C0660072F691F
3 changed files with 6 additions and 15 deletions

View File

@ -23,7 +23,6 @@ fn send(req &string) ?http.Response {
// Write the request to the socket
s.write_string(req) ?
s.wait_for_write() ?
mut c := 0
@ -63,11 +62,10 @@ fn send(req &string) ?http.Response {
// Decode chunked response
return http.parse_response(res.bytestr())
}
fn request_with_body(method string, url urllib.URL, body &string) ?http.Response {
req := '$method $url.request_uri() HTTP/1.1\nHost: localhost\nContent-Length: ${body.len}\n$body\n'
req := '$method $url.request_uri() HTTP/1.1\nHost: localhost\nContent-Length: $body.len\n$body\n'
return send(req)
}
@ -80,7 +78,6 @@ fn request(method string, url urllib.URL) ?http.Response {
pub fn request_with_json<T>(method string, url urllib.URL, data T) ?http.Response {
body := json.encode(data)
println(body)
return request_with_body(method, url, body)
}
@ -95,11 +92,5 @@ struct ImagePull {
}
pub fn pull(image string, tag string) ?http.Response {
// data := ImagePull{
// from_image: image
// tag: tag
// }
// return request_with_json("POST", urllib.parse("/images/create") ?, data)
return request("POST", urllib.parse("/images/create?fromImage=$image&tag=$tag") ?)
return request('POST', urllib.parse('/images/create?fromImage=$image&tag=$tag') ?)
}