diff --git a/main.go b/main.go index 86547a0..65e2ddf 100644 --- a/main.go +++ b/main.go @@ -10,16 +10,16 @@ import ( "github.com/jpillora/opts" "github.com/jpillora/requestlog" - "github.com/jpillora/serve/handler" + "github.com/jpillora/serve/serve" ) var VERSION string = "0.0.0" type Config struct { - Host string `help:"Host interface"` - Port int `help:"Listening port"` - Open bool `help:"On server startup, open the root in the default browser (uses the 'open' command)"` - handler.Config `type:"embedded"` + Host string `help:"Host interface"` + Port int `help:"Listening port"` + Open bool `help:"On server startup, open the root in the default browser (uses the 'open' command)"` + serve.Config `type:"embedded"` } func main() { @@ -28,7 +28,7 @@ func main() { c := Config{ Host: "0.0.0.0", Port: 3000, - Config: handler.Config{ + Config: serve.Config{ Directory: ".", }, } @@ -41,7 +41,7 @@ func main() { Parse() //ready! - h, err := handler.New(c.Config) + h, err := serve.NewHandler(c.Config) if err != nil { log.Fatal(err) } diff --git a/handler/handler_config.go b/serve/config.go similarity index 98% rename from handler/handler_config.go rename to serve/config.go index 1f29596..d54b1c0 100644 --- a/handler/handler_config.go +++ b/serve/config.go @@ -1,4 +1,4 @@ -package handler +package serve //Config is a handler configuration type Config struct { diff --git a/handler/handler.go b/serve/handler.go similarity index 97% rename from handler/handler.go rename to serve/handler.go index dfe726d..11873cd 100644 --- a/handler/handler.go +++ b/serve/handler.go @@ -1,4 +1,4 @@ -package handler +package serve import ( "fmt" @@ -32,12 +32,8 @@ type Handler struct { lr *lrserver.Server } -func Directory(dir string) (http.Handler, error) { - return New(Config{Directory: dir}) -} - //NewServer creates a new Server -func New(c Config) (http.Handler, error) { +func NewHandler(c Config) (http.Handler, error) { s := &Handler{ c: c, served: map[string]bool{}, diff --git a/handler/handler_dirlist.go b/serve/handler_dirlist.go similarity index 99% rename from handler/handler_dirlist.go rename to serve/handler_dirlist.go index b811bce..652cd5b 100644 --- a/handler/handler_dirlist.go +++ b/serve/handler_dirlist.go @@ -1,4 +1,4 @@ -package handler +package serve import ( "bytes" diff --git a/handler/utils.go b/serve/utils.go similarity index 95% rename from handler/utils.go rename to serve/utils.go index 53de2e9..459c0a2 100644 --- a/handler/utils.go +++ b/serve/utils.go @@ -1,4 +1,4 @@ -package handler +package serve import ( "os/user"