summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/rhimportd/ctrlWeb.go5
-rw-r--r--src/rhimportd/main.go4
-rw-r--r--src/rhimportd/uploadWeb.go2
-rw-r--r--web-static/upload-form.html (renamed from html/upload-form.html)2
4 files changed, 8 insertions, 5 deletions
diff --git a/src/rhimportd/ctrlWeb.go b/src/rhimportd/ctrlWeb.go
index 6bee325..2b52ef0 100644
--- a/src/rhimportd/ctrlWeb.go
+++ b/src/rhimportd/ctrlWeb.go
@@ -44,9 +44,10 @@ func (self webHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
self.H(self.Config, self.DBChan, self.SessionStoreChan, self.trusted, w, r)
}
-func StartControlWeb(addr string, uploadMaxAge time.Duration, conf *rhimport.Config, db *rddb.DBChan, sessions *rhimport.SessionStoreChan) {
- // http.Handle("/trusted/simple", webHandler{conf, db, sessions, true, webSimpleHandler})
+func StartControlWeb(addr, staticDir string, uploadMaxAge time.Duration, conf *rhimport.Config, db *rddb.DBChan, sessions *rhimport.SessionStoreChan) {
+ http.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.Dir(staticDir))))
+ // http.Handle("/trusted/simple", webHandler{conf, db, sessions, true, webSimpleHandler})
http.Handle("/public/simple", webHandler{conf, db, sessions, false, webSimpleHandler})
http.Handle("/public/socket", webHandler{conf, db, sessions, false, webSocketHandler})
http.Handle("/public/upload", webHandler{conf, db, sessions, false, webUploadHandler})
diff --git a/src/rhimportd/main.go b/src/rhimportd/main.go
index 68b0177..97a12ec 100644
--- a/src/rhimportd/main.go
+++ b/src/rhimportd/main.go
@@ -92,6 +92,8 @@ func (d *envDurationValue) String() string { return fmt.Sprintf("%v", *d) }
func main() {
webAddr := newEnvStringValue("RHIMPORTD_WEB_ADDR", "localhost:4080")
flag.Var(webAddr, "web-addr", "addr:port to listen on (environment: RHIMPORTD_WEB_ADDR)")
+ webStaticDir := newEnvStringValue("RHIMPORTD_WEB_STATIC_DIR", "/usr/share/rhimportd/web-static/")
+ flag.Var(webStaticDir, "web-static-dir", "path to static html files (environment: RHIMPORTD_WEB_STATIC_DIR)")
telnetAddr := newEnvStringValue("RHIMPORTD_TELNET_ADDR", "localhost:4023")
flag.Var(telnetAddr, "telnet-addr", "addr:port to listen on (environment: RHIMPORTD_TELNET_ADDR)")
watchDir := newEnvStringValue("RHIMPORTD_WATCH_DIR", "")
@@ -143,7 +145,7 @@ func main() {
go func() {
defer wg.Done()
rhl.Println("starting web-ctrl")
- StartControlWeb(webAddr.Get().(string), uploadMaxAge.Get().(time.Duration), conf, db.GetInterface(), sessions.GetInterface())
+ StartControlWeb(webAddr.Get().(string), webStaticDir.Get().(string), uploadMaxAge.Get().(time.Duration), conf, db.GetInterface(), sessions.GetInterface())
rhl.Println("web-ctrl finished")
}()
}
diff --git a/src/rhimportd/uploadWeb.go b/src/rhimportd/uploadWeb.go
index 3a4e7bc..4dc0368 100644
--- a/src/rhimportd/uploadWeb.go
+++ b/src/rhimportd/uploadWeb.go
@@ -64,7 +64,7 @@ const (
func webUploadHandler(conf *rhimport.Config, db *rddb.DBChan, sessions *rhimport.SessionStoreChan, trusted bool, w http.ResponseWriter, r *http.Request) {
if r.Method == "GET" {
- http.ServeFile(w, r, "./html/upload-form.html") // TODO: hardcoded html-dir... should we print the html directly?
+ http.Redirect(w, r, "/static/upload-form.html", http.StatusTemporaryRedirect)
return
}
diff --git a/html/upload-form.html b/web-static/upload-form.html
index 1718b1b..bbb397c 100644
--- a/html/upload-form.html
+++ b/web-static/upload-form.html
@@ -6,7 +6,7 @@
<body>
<div class="container">
<h1>rhimportd File Upload</h1>
- <form class="form-upload" method="post" enctype="multipart/form-data">
+ <form class="form-upload" method="post" action="/public/upload" enctype="multipart/form-data">
<fieldset>
<label for="LOGIN_NAME">Username:</label>
<input type="text" name="LOGIN_NAME">