summaryrefslogtreecommitdiff
path: root/cmd/dolmetschctld/web.go
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/dolmetschctld/web.go')
-rw-r--r--cmd/dolmetschctld/web.go11
1 files changed, 7 insertions, 4 deletions
diff --git a/cmd/dolmetschctld/web.go b/cmd/dolmetschctld/web.go
index ade1e82..696169f 100644
--- a/cmd/dolmetschctld/web.go
+++ b/cmd/dolmetschctld/web.go
@@ -24,7 +24,6 @@ package main
import (
"encoding/json"
- "log"
"net/http"
"time"
)
@@ -76,8 +75,6 @@ func webLanguageHandler(sm *StateMachine, w http.ResponseWriter, r *http.Request
return
}
- log.Printf("web: got request %v", result)
-
if err := sm.SetLanguage(result.Lang); err != nil {
webSendErrorResponse(w, http.StatusBadRequest, err.Error())
return
@@ -106,12 +103,18 @@ func (web *WebInterface) Run() error {
return web.server.ListenAndServe()
}
-func NewWebInterface(addr string, sm *StateMachine) (web *WebInterface, err error) {
+func NewWebInterface(addr, staticDir string, sm *StateMachine) (web *WebInterface, err error) {
web = &WebInterface{}
+ if staticDir != "" {
+ http.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.Dir(staticDir))))
+ }
+
http.Handle("/api/v1/state", webHandler{sm, webStateHandler})
http.Handle("/api/v1/language", webHandler{sm, webLanguageHandler})
+ http.Handle("/api/v1/socket", webHandler{sm, webSocketHandler})
+
web.server = &http.Server{Addr: addr, ReadTimeout: 2 * time.Hour, WriteTimeout: 2 * time.Hour}
return
}