1
0
Fork 0
mirror of https://github.com/FrankerFaceZ/FrankerFaceZ.git synced 2025-08-02 07:58:31 +00:00

Defaults in the config file are a nice thing to have

This commit is contained in:
Kane York 2015-10-27 18:22:56 -07:00
parent c5f53657cb
commit 787f5a1caa
2 changed files with 21 additions and 23 deletions

View file

@ -6,7 +6,6 @@ import (
"errors"
"fmt"
"golang.org/x/net/websocket"
"html/template"
"log"
"net/http"
"strconv"
@ -112,37 +111,18 @@ func SetupServerAndHandle(config *ConfigFile, tlsConfig *tls.Config, serveMux *h
serveMux = http.DefaultServeMux
}
serveMux.HandleFunc("/", ServeWebsocketOrCatbag(sockServer.ServeHTTP))
serveMux.Handle("/assets", http.FileServer(nil)) // TODO
serveMux.HandleFunc("/pub_msg", HBackendPublishRequest)
serveMux.HandleFunc("/dump_backlog", HBackendDumpBacklog)
serveMux.HandleFunc("/update_and_pub", HBackendUpdateAndPublish)
}
var Memes = template.Must(template.New("catbag").Parse(`
<!DOCTYPE html>
<title>CatBag</title>
<link rel="stylesheet" href="//cdn.frankerfacez.com/script/catbag.css">
<div id="container">
<div id="zf0"></div><div id="zf1"></div><div id="zf2"></div>
<div id="zf3"></div><div id="zf4"></div><div id="zf5"></div>
<div id="zf6"></div><div id="zf7"></div><div id="zf8"></div>
<div id="zf9"></div><div id="catbag"></div>
<div id="bottom">
A <a href="http://www.frankerfacez.com/">FrankerFaceZ</a> Service
&mdash; CatBag by <a href="http://www.twitch.tv/wolsk">Wolsk</a>
<br>
This socket server hosted by {{.}}
</div>
</div>
`))
func ServeWebsocketOrCatbag(sockfunc func(http.ResponseWriter, *http.Request)) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
if r.Header.Get("Connection") == "Upgrade" {
sockfunc(w, r)
return
} else {
Memes.Execute(w, "Todo Add Feature")
w.Write([]byte(gconfig.BannerHTML))
}
}
}