1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

http: PATCH, DELETE, and PUT methods

This commit is contained in:
Kai 2020-01-14 15:19:50 -07:00 committed by Alexander Medvednikov
parent 4838dda59a
commit 9f31390ff1

View File

@ -35,13 +35,23 @@ pub:
}
pub fn get(url string) ?Response {
req := new_request('GET', url, '') or {
return error(err)
}
res := req.do() or {
return error(err)
}
return res
return method('GET', url, '')
}
pub fn head(url string) ?Response {
return method('HEAD', url, '')
}
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 {
@ -54,13 +64,9 @@ pub fn post(url, data string) ?Response {
return res
}
pub fn head(url string) ?Response {
req := new_request('HEAD', url, '') or {
return error(err)
}
res := req.do() or {
return error(err)
}
pub fn method(mname string, url string, data string) ?Response {
req := new_request(mname, url, data) or { return error(err) }
res := req.do() or { return error(err)}
return res
}