Skip to content
This repository was archived by the owner on Jan 20, 2020. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions boxcars/boxcars.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ func main() {
os.Exit(1)
}

if secure {
boxcars.Secure(user_id, group_id)
}

boxcars.SetFilename(filename)
go boxcars.ReadConfig()
go boxcars.AutoReload()

if secure {
go boxcars.Secure(user_id, group_id)
}

boxcars.Listen(port)
}
13 changes: 13 additions & 0 deletions handlers-of.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import (
"regexp"
"fmt"
"os"
"os/user"
"strings"
)

type Handlers map[string]*Handler
Expand All @@ -12,6 +14,7 @@ func handlerOf (uri string, hasCustom404 bool, custom404 string) *Handler {
debug("Setting up the HTTP handler that will serve %s", uri)

handler := &Handler{ false, false, uri, nil }
uri = expandUser(uri)
isStatic := isLocalPath(uri)

if isStatic && isSingleFile(uri) {
Expand Down Expand Up @@ -76,3 +79,13 @@ func isSingleFile (uri string) bool {

return false
}

func expandUser(uri string) string {
if !strings.HasPrefix(uri, "~/") {
return uri
}
usr, _ := user.Current()
dir := usr.HomeDir
uri = strings.Replace(uri, "~", dir, 1)
return uri
}