mirror of
https://github.com/sorenisanerd/gotty.git
synced 2024-11-09 23:34:26 +00:00
Add 'Server' HTTP header with current GoTTY version
$ curl -I http://gotty.server/ HTTP/1.1 200 OK Accept-Ranges: bytes Content-Length: 407 Content-Type: text/html; charset=utf-8 Last-Modified: Fri, 02 Oct 2015 08:04:28 GMT Server: GoTTY/0.0.10 Date: Fri, 02 Oct 2015 08:04:28 GMT
This commit is contained in:
parent
096f77c780
commit
f75cc9771a
11
app/app.go
11
app/app.go
@ -53,6 +53,8 @@ type Options struct {
|
||||
Preferences map[string]interface{} `hcl:"preferences"`
|
||||
}
|
||||
|
||||
var Version = "0.0.10"
|
||||
|
||||
var DefaultOptions = Options{
|
||||
Address: "",
|
||||
Port: "8080",
|
||||
@ -154,6 +156,8 @@ func (app *App) Run() error {
|
||||
siteHandler = wrapBasicAuth(siteHandler, app.options.Credential)
|
||||
}
|
||||
|
||||
siteHandler = wrapHeaders(siteHandler)
|
||||
|
||||
wsMux := http.NewServeMux()
|
||||
wsMux.Handle("/", siteHandler)
|
||||
wsMux.Handle(path+"/ws", wsHandler)
|
||||
@ -277,6 +281,13 @@ func wrapLogger(handler http.Handler) http.Handler {
|
||||
})
|
||||
}
|
||||
|
||||
func wrapHeaders(handler http.Handler) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Server", "GoTTY/"+Version)
|
||||
handler.ServeHTTP(w, r)
|
||||
})
|
||||
}
|
||||
|
||||
func wrapBasicAuth(handler http.Handler, credential string) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
token := strings.SplitN(r.Header.Get("Authorization"), " ", 2)
|
||||
|
Loading…
Reference in New Issue
Block a user