summaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
Diffstat (limited to 'main.go')
-rw-r--r--main.go15
1 files changed, 15 insertions, 0 deletions
diff --git a/main.go b/main.go
index 3ed3e9c..3dcdc2e 100644
--- a/main.go
+++ b/main.go
@@ -128,6 +128,7 @@ func main() {
}(stopch)
http.HandleFunc("/", startpage)
+ http.HandleFunc("/bgimg", bgimg)
log.Fatal(http.ListenAndServe(*laddr, nil))
}
@@ -143,3 +144,17 @@ func startpage(rw http.ResponseWriter, req *http.Request) {
log.Printf("Failed executing template: %s\n", err)
}
}
+
+func bgimg(rw http.ResponseWriter, req *http.Request) {
+ defer req.Body.Close()
+
+ if len(porn.data) == 0 {
+ rw.WriteHeader(http.StatusNotFound)
+ }
+
+ rw.Header().Add("Content-Type", porn.mediatype)
+ if _, err := rw.Write(porn.data); err != nil {
+ log.Printf("Failed serving background: %s", err)
+ }
+}
+