From cb908eb1945d695f9bdcc4348dde0d81ed099cc7 Mon Sep 17 00:00:00 2001 From: Paul Lecuq Date: Sun, 26 Jan 2020 18:03:09 +0100 Subject: [PATCH] updated dip structure --- .gitignore | 2 +- cmd/dip/main.go | 36 ++++++++++++++++++++++++++++++++ src/{ => dip}/dip.go | 2 +- src/{ => ip}/ip.go | 0 src/{ => static}/static.go | 0 src/{ => templates}/templates.go | 0 6 files changed, 38 insertions(+), 2 deletions(-) create mode 100644 cmd/dip/main.go rename src/{ => dip}/dip.go (90%) rename src/{ => ip}/ip.go (100%) rename src/{ => static}/static.go (100%) rename src/{ => templates}/templates.go (100%) diff --git a/.gitignore b/.gitignore index d9977cc..906b7f5 100644 --- a/.gitignore +++ b/.gitignore @@ -16,4 +16,4 @@ *.swp *.ini -dip +/dip diff --git a/cmd/dip/main.go b/cmd/dip/main.go new file mode 100644 index 0000000..b482f08 --- /dev/null +++ b/cmd/dip/main.go @@ -0,0 +1,36 @@ +package main + +import ( + "flag" + "fmt" + + "git.paulbsd.com/paulbsd/dip/packrd" + "git.paulbsd.com/paulbsd/dip/src" + "github.com/gobuffalo/packr/v2" + "github.com/labstack/echo/v4" +) + +func main() { + e := echo.New() + e.HideBanner = true + + var host, port string + + flag.Usage = dip.Usage + flag.StringVar(&host, "host", "[::]", "Listen host") + flag.StringVar(&port, "port", "8080", "Listen port") + flag.Parse() + + templatesbox := packr.New("templates", "./templates") + staticbox := packr.New("static", "./static") + + builtTemplates, _ := templates.BuildTemplates(templatesbox) + e.Renderer = builtTemplates + + e.GET("/", dip.Dip) + e.GET("/static/*", func(c echo.Context) error { + return static.Static(staticbox, c) + }) + + e.Logger.Fatal(e.Start(fmt.Sprintf("%s:%s", host, port))) +} diff --git a/src/dip.go b/src/dip/dip.go similarity index 90% rename from src/dip.go rename to src/dip/dip.go index 953da62..394e857 100644 --- a/src/dip.go +++ b/src/dip/dip.go @@ -1,7 +1,7 @@ package dip import ( - "git.paulbsd.com/paulbsd/dip/src/ip" + "git.paulbsd.com/paulbsd/dip/src" "github.com/labstack/echo/v4" "net/http" "strings" diff --git a/src/ip.go b/src/ip/ip.go similarity index 100% rename from src/ip.go rename to src/ip/ip.go diff --git a/src/static.go b/src/static/static.go similarity index 100% rename from src/static.go rename to src/static/static.go diff --git a/src/templates.go b/src/templates/templates.go similarity index 100% rename from src/templates.go rename to src/templates/templates.go