From 01527c861cf67f585e1cda721f7535e4488dcb93 Mon Sep 17 00:00:00 2001 From: Jaime Pillora Date: Wed, 2 Sep 2015 11:20:45 +1000 Subject: [PATCH] **API Change** renamed library package --- main.go | 14 +++++++------- handler/handler_config.go => serve/config.go | 2 +- {handler => serve}/handler.go | 8 ++------ {handler => serve}/handler_dirlist.go | 2 +- {handler => serve}/utils.go | 2 +- 5 files changed, 12 insertions(+), 16 deletions(-) rename handler/handler_config.go => serve/config.go (98%) rename {handler => serve}/handler.go (97%) rename {handler => serve}/handler_dirlist.go (99%) rename {handler => serve}/utils.go (95%) 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"