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

net.http: copy IANA's list of methods to the http.Method enum (#18508)

This commit is contained in:
Joe Koop 2023-06-22 01:31:34 -05:00 committed by GitHub
parent 76ae9dba5c
commit 8b25c4c9a3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3,33 +3,92 @@
// that can be found in the LICENSE file.
module http
// The methods listed here are some of the most used ones, ordered by
// commonality. A comprehensive list is available at:
// The methods listed here are all of those on the list available at:
// https://www.iana.org/assignments/http-methods/http-methods.xhtml
pub enum Method {
get
post
put
head
delete
options
trace
pub enum Method { // as of 2023-06-20
acl
baseline_control
bind
checkin
checkout
connect
copy
delete
get
head
label
link
@lock
merge
mkactivity
mkcalendar
mkcol
mkredirectref
mkworkspace
move
options
orderpatch
patch
post
pri
propfind
proppatch
put
rebind
report
search
trace
unbind
uncheckout
unlink
unlock
update
updateredirectref
version_control
}
// str returns the string representation of the HTTP Method `m`.
pub fn (m Method) str() string {
return match m {
.get { 'GET' }
.post { 'POST' }
.put { 'PUT' }
.head { 'HEAD' }
.delete { 'DELETE' }
.options { 'OPTIONS' }
.trace { 'TRACE' }
.post { 'POST' }
.acl { 'ACL' }
.baseline_control { 'BASELINE-CONTROL' }
.bind { 'BIND' }
.checkin { 'CHECKIN' }
.checkout { 'CHECKOUT' }
.connect { 'CONNECT' }
.copy { 'COPY' }
.delete { 'DELETE' }
.label { 'LABEL' }
.link { 'LINK' }
.@lock { 'LOCK' }
.merge { 'MERGE' }
.mkactivity { 'MKACTIVITY' }
.mkcalendar { 'MKCALENDAR' }
.mkcol { 'MKCOL' }
.mkredirectref { 'MKREDIRECTREF' }
.mkworkspace { 'MKWORKSPACE' }
.move { 'MOVE' }
.options { 'OPTIONS' }
.orderpatch { 'ORDERPATCH' }
.patch { 'PATCH' }
.pri { 'PRI' }
.propfind { 'PROPFIND' }
.proppatch { 'PROPPATCH' }
.put { 'PUT' }
.rebind { 'REBIND' }
.report { 'REPORT' }
.search { 'SEARCH' }
.trace { 'TRACE' }
.unbind { 'UNBIND' }
.uncheckout { 'UNCHECKOUT' }
.unlink { 'UNLINK' }
.unlock { 'UNLOCK' }
.update { 'UPDATE' }
.updateredirectref { 'UPDATEREDIRECTREF' }
.version_control { 'VERSION-CONTROL' }
}
}
@ -40,14 +99,44 @@ pub fn (m Method) str() string {
pub fn method_from_str(m string) Method {
return match m {
'GET' { Method.get }
'POST' { Method.post }
'PUT' { Method.put }
'HEAD' { Method.head }
'DELETE' { Method.delete }
'OPTIONS' { Method.options }
'TRACE' { Method.trace }
'POST' { Method.post }
'ACL' { Method.acl }
'BASELINE-CONTROL' { Method.baseline_control }
'BIND' { Method.bind }
'CHECKIN' { Method.checkin }
'CHECKOUT' { Method.checkout }
'CONNECT' { Method.connect }
'COPY' { Method.copy }
'DELETE' { Method.delete }
'LABEL' { Method.label }
'LINK' { Method.link }
'LOCK' { Method.@lock }
'MERGE' { Method.merge }
'MKACTIVITY' { Method.mkactivity }
'MKCALENDAR' { Method.mkcalendar }
'MKCOL' { Method.mkcol }
'MKREDIRECTREF' { Method.mkredirectref }
'MKWORKSPACE' { Method.mkworkspace }
'MOVE' { Method.move }
'OPTIONS' { Method.options }
'ORDERPATCH' { Method.orderpatch }
'PATCH' { Method.patch }
'PRI' { Method.pri }
'PROPFIND' { Method.propfind }
'PROPPATCH' { Method.proppatch }
'PUT' { Method.put }
'REBIND' { Method.rebind }
'REPORT' { Method.report }
'SEARCH' { Method.search }
'TRACE' { Method.trace }
'UNBIND' { Method.unbind }
'UNCHECKOUT' { Method.uncheckout }
'UNLINK' { Method.unlink }
'UNLOCK' { Method.unlock }
'UPDATE' { Method.update }
'UPDATEREDIRECTREF' { Method.updateredirectref }
'VERSION-CONTROL' { Method.version_control }
else { Method.get } // should we default to GET?
}
}