mirror of
https://github.com/rancher/norman.git
synced 2025-09-03 16:25:09 +00:00
add yaml support
This commit is contained in:
committed by
Darren Shepherd
parent
79b91ea33c
commit
59c4a298e8
@@ -23,6 +23,7 @@ var (
|
||||
allowedFormats = map[string]bool{
|
||||
"html": true,
|
||||
"json": true,
|
||||
"yaml": true,
|
||||
}
|
||||
)
|
||||
|
||||
@@ -259,9 +260,17 @@ func parseResponseFormat(req *http.Request) string {
|
||||
if IsBrowser(req, true) {
|
||||
return "html"
|
||||
}
|
||||
|
||||
if isYaml(req) {
|
||||
return "yaml"
|
||||
}
|
||||
return "json"
|
||||
}
|
||||
|
||||
func isYaml(req *http.Request) bool {
|
||||
return strings.Contains(req.Header.Get("Accept"), "application/yaml")
|
||||
}
|
||||
|
||||
func parseMethod(req *http.Request) string {
|
||||
method := req.URL.Query().Get("_method")
|
||||
if method == "" {
|
||||
|
Reference in New Issue
Block a user