Skip to content

Commit

Permalink
support manage-assets = true
Browse files Browse the repository at this point in the history
  • Loading branch information
kelyar committed Sep 3, 2013
1 parent 66d133a commit 54b6010
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions core/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,16 @@ import (
"github.com/pallada/clio/vendor/go.grace/gracehttp"
)

func requestHandler () http.Handler {
func requestHandler (settings map[string]interface{}) http.Handler {

mux := http.NewServeMux()

serveStatic := settings["manage-assets"].(bool)
if serveStatic {
fs := http.FileServer(http.Dir("public"))
mux.Handle("/assets/", http.StripPrefix("/assets/", fs))
}

mux.HandleFunc("/", func (w http.ResponseWriter, req *http.Request) {

// setting up package variable to use outside the package
Expand All @@ -26,7 +34,7 @@ func Run (settings map[string]interface {}) {
port := strconv.Itoa(settings["port"].(int))

gracehttp.Serve (
&http.Server { Addr: ":" + port, Handler: requestHandler () },
&http.Server { Addr: ":" + port, Handler: requestHandler (settings) },
)
}

Expand Down

0 comments on commit 54b6010

Please sign in to comment.