Skip to content

Commit 4e58af4

Browse files
authored
Merge branch 'develop' into json-params
2 parents 116f4e9 + 523f6c6 commit 4e58af4

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

http.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
"strings"
1414

1515
"golang.org/x/net/websocket"
16+
"path/filepath"
1617
)
1718

1819
// Request Revel's HTTP request object structure
@@ -78,6 +79,18 @@ func ResolveContentType(req *http.Request) string {
7879
// returning a default of "html" when Accept header cannot be mapped to a
7980
// value above.
8081
func ResolveFormat(req *http.Request) string {
82+
ext := strings.ToLower(filepath.Ext(req.URL.Path))
83+
switch ext {
84+
case ".html":
85+
return "html"
86+
case ".json":
87+
return "json"
88+
case ".xml":
89+
return "xml"
90+
case ".txt":
91+
return "txt"
92+
}
93+
8194
accept := req.Header.Get("accept")
8295

8396
switch {

0 commit comments

Comments
 (0)