1
0
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:
Daishan Peng
2018-05-24 10:28:05 -07:00
committed by Darren Shepherd
parent 79b91ea33c
commit 59c4a298e8
7 changed files with 80 additions and 20 deletions

View File

@@ -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 == "" {