http: PATCH, DELETE, and PUT methods

pull/3450/head
Kai 2020-01-14 15:19:50 -07:00 committed by Alexander Medvednikov
parent 4838dda59a
commit 9f31390ff1
1 changed files with 21 additions and 15 deletions

View File

@ -34,14 +34,24 @@ pub:
status_code int status_code int
} }
pub fn get(url string) ?Response { pub fn get(url string) ?Response {
req := new_request('GET', url, '') or { return method('GET', url, '')
return error(err) }
}
res := req.do() or { pub fn head(url string) ?Response {
return error(err) return method('HEAD', url, '')
} }
return res
pub fn delete(url string) ?Response {
return method('DELETE', url, '')
}
pub fn patch(url string) ?Response {
return method('PATCH', url, '')
}
pub fn put(url string) ?Response {
return method('PUT', url, '')
} }
pub fn post(url, data string) ?Response { pub fn post(url, data string) ?Response {
@ -54,13 +64,9 @@ pub fn post(url, data string) ?Response {
return res return res
} }
pub fn head(url string) ?Response { pub fn method(mname string, url string, data string) ?Response {
req := new_request('HEAD', url, '') or { req := new_request(mname, url, data) or { return error(err) }
return error(err) res := req.do() or { return error(err)}
}
res := req.do() or {
return error(err)
}
return res return res
} }