|
@@ -42,11 +42,6 @@ var (
|
|
currRenderer Renderer
|
|
currRenderer Renderer
|
|
Render map[string]func(http.ResponseWriter, *http.Request, interface{}, ...url.Values)
|
|
Render map[string]func(http.ResponseWriter, *http.Request, interface{}, ...url.Values)
|
|
|
|
|
|
- funcMap = template.FuncMap{
|
|
|
|
- "query": query,
|
|
|
|
- "convertDate": convertDate,
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
contentTypeToFormat = map[string]string{
|
|
contentTypeToFormat = map[string]string{
|
|
"application/x-www-form-urlencoded": "html",
|
|
"application/x-www-form-urlencoded": "html",
|
|
"application/json": "json",
|
|
"application/json": "json",
|
|
@@ -100,22 +95,6 @@ func Query(values ...string) template.URL {
|
|
return query(values...)
|
|
return query(values...)
|
|
}
|
|
}
|
|
|
|
|
|
-func query(values ...string) template.URL {
|
|
|
|
- var urlValues url.Values
|
|
|
|
-
|
|
|
|
- urlValues = make(url.Values)
|
|
|
|
- urlValues.Set("format", "html")
|
|
|
|
-
|
|
|
|
- for i := 0; i < len(values); i += 2 {
|
|
|
|
- urlValues.Add(values[i], values[i+1])
|
|
|
|
- }
|
|
|
|
- return template.URL(urlValues.Encode())
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-func convertDate(t time.Time) string {
|
|
|
|
- return fmt.Sprintf("%d-%02d-%02d", t.Year(), t.Month(), t.Day())
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
// FIXME: Not safe. We should check if it responds to the error interface instead.
|
|
// FIXME: Not safe. We should check if it responds to the error interface instead.
|
|
func isErrorType(data interface{}) bool {
|
|
func isErrorType(data interface{}) bool {
|
|
return strings.Contains(strings.ToLower(reflect.TypeOf(data).String()), "error")
|
|
return strings.Contains(strings.ToLower(reflect.TypeOf(data).String()), "error")
|