", statusStr, title)
+ fmt.Fprintf(w, "%s", body)
+ fmt.Fprintf(w, "")
+ fmt.Fprintf(w, "")
+}
+
func respond(w http.ResponseWriter, req *http.Request, status Status, short string, format string, a ...interface{}) {
long := fmt.Sprintf(format, a...)
// This is a kludge. Do proper parsing when this causes problems.
diff --git a/src/static.go b/src/static.go
index 1630c50..41a60bc 100644
--- a/src/static.go
+++ b/src/static.go
@@ -1,7 +1,6 @@
package main
import (
- "encoding/json"
"fmt"
"net/http"
"os"
@@ -17,63 +16,6 @@ const (
Error
)
-// ShowJSend renders a JSend response to w
-func ShowJSend(w http.ResponseWriter, status Status, short string, description string) {
- w.Header().Set("Content-Type", "application/json")
- w.WriteHeader(http.StatusOK) // RFC2616 makes it pretty clear that 4xx codes are for the user-agent
-
- statusStr := ""
- switch status {
- case Success:
- statusStr = "success"
- case Fail:
- statusStr = "fail"
- default:
- statusStr = "error"
- }
-
- jshort, _ := json.Marshal(short)
- jdesc, _ := json.Marshal(description)
- fmt.Fprintf(
- w,
- `{"status":"%s","data":{"short":%s,"description":%s}}"`,
- statusStr, jshort, jdesc,
- )
-}
-
-// ShowHtml delevers an HTML response to w
-func ShowHtml(w http.ResponseWriter, status Status, title string, body string) {
- w.Header().Set("Content-Type", "text/html; charset=utf-8")
- w.WriteHeader(http.StatusOK)
-
- statusStr := ""
- switch status {
- case Success:
- statusStr = "Success"
- case Fail:
- statusStr = "Fail"
- default:
- statusStr = "Error"
- }
-
- fmt.Fprintf(w, "")
- fmt.Fprintf(w, "")
- fmt.Fprintf(w, "%s", title)
- fmt.Fprintf(w, "")
- fmt.Fprintf(w, "")
- fmt.Fprintf(w, "")
- fmt.Fprintf(w, "")
- fmt.Fprintf(w, "
%s
", statusStr, title)
- fmt.Fprintf(w, "%s", body)
- fmt.Fprintf(w, "")
- fmt.Fprintf(w, "")
-}
-
// staticStylesheet serves up a basic stylesheet.
// This is designed to be usable on small touchscreens (like mobile phones)
func staticStylesheet(w http.ResponseWriter) {