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:
parent
c5f53657cb
commit
787f5a1caa
2 changed files with 21 additions and 23 deletions
|
@ -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
|
||||
— 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))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue