Skip to content
This repository has been archived by the owner on Sep 25, 2018. It is now read-only.

Commit

Permalink
add redirect
Browse files Browse the repository at this point in the history
  • Loading branch information
codeskyblue committed Feb 11, 2015
1 parent 6d788bf commit 9867061
Show file tree
Hide file tree
Showing 3 changed files with 268 additions and 3 deletions.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
#

all:
go-bindata templates public
go-bindata templates public/...
go build
GOOS=windows GOARCH=386 go build


# vim:ft=make
Expand Down
261 changes: 261 additions & 0 deletions bindata.go

Large diffs are not rendered by default.

7 changes: 5 additions & 2 deletions file-server.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ func restoreAssets() {
selfDir := filepath.Dir(os.Args[0])
for _, folder := range []string{"templates", "public"} {
if _, err := os.Stat(folder); err != nil {
if er := RestoreAssets(selfDir, "templates"); err != nil {
log.Fatal(er)
if er := RestoreAssets(selfDir, folder); er != nil {
log.Fatal("RestoreAssets", er)
}
}
}
Expand All @@ -106,6 +106,9 @@ func main() {
// extract files
restoreAssets()

m.Get("/", func(w http.ResponseWriter, r *http.Request) {
http.Redirect(w, r, "/files/", http.StatusTemporaryRedirect)
})
m.Get("/files/**", func(req *http.Request, w http.ResponseWriter, params martini.Params, r render.Render) {
path := params["_1"]
if path == "" {
Expand Down

0 comments on commit 9867061

Please sign in to comment.