diff --git a/config/config.go b/config/config.go
index 1844511..148ded6 100644
--- a/config/config.go
+++ b/config/config.go
@@ -6,7 +6,8 @@ import (
)
var (
- Port string
+ Port string
+ Public string
)
func init() {
@@ -16,8 +17,10 @@ func init() {
func New() {
as := args.NewArgSet()
as.Append(args.INT, "p", "port to listen on", 52222)
+ as.Append(args.STRING, "d", "dir with public files", "./public")
if err := as.Parse(); err != nil {
panic(err)
}
Port = fmt.Sprintf(":%d", as.GetInt("p"))
+ Public = as.GetString("d")
}
diff --git a/public/index.html b/public/index.html
new file mode 100644
index 0000000..73d7d6f
--- /dev/null
+++ b/public/index.html
@@ -0,0 +1,8 @@
+
+
+
+
+
+ Hi
+
+
diff --git a/server/routes.go b/server/routes.go
index 2d8eec0..eba530f 100644
--- a/server/routes.go
+++ b/server/routes.go
@@ -1,9 +1,12 @@
package server
import (
+ "fmt"
+ "local/cheqbooq/config"
"local/cheqbooq/server/account"
"local/cheqbooq/server/balance"
"local/cheqbooq/server/transaction"
+ "local/router"
"net/http"
)
@@ -12,6 +15,7 @@ func (s *Server) Routes() error {
"api/v1/balance": s.balance1,
"api/v1/transaction": s.transaction1,
"api/v1/account": s.account1,
+ fmt.Sprintf("%s%s", router.Wildcard, router.Wildcard): s.public,
}
for path, handler := range routes {
if err := s.Add(path, handler); err != nil {
@@ -51,3 +55,8 @@ func (s *Server) account1(w http.ResponseWriter, r *http.Request) {
http.NotFound(w, r)
}
}
+
+func (s *Server) public(w http.ResponseWriter, r *http.Request) {
+ d := http.FileServer(http.Dir(config.Public))
+ d.ServeHTTP(w, r)
+}