diff --git a/cmd/lash/main.go b/cmd/lash/main.go index b91de7d..75d4b02 100644 --- a/cmd/lash/main.go +++ b/cmd/lash/main.go @@ -2,13 +2,24 @@ package main import ( _ "embed" + "flag" + "fmt" "lash" "lash/internal/app" "lash/internal/errx" "net/http" ) +var versionFlag = flag.Bool("version", false, "Print out version and exit.") + func main() { + flag.Parse() + + if *versionFlag { + fmt.Print("lash/vxc v", lash.Version) + return + } + srv := app.New() errx.Log("Your token is \033[1;92m%s\033[0m", lash.Token) diff --git a/internal/handlers/share.go b/internal/handlers/share.go index 57d1757..ec11449 100644 --- a/internal/handlers/share.go +++ b/internal/handlers/share.go @@ -2,8 +2,9 @@ package handlers import ( "html/template" - "lash" "net/http" + + "lash" ) type ShareData struct { @@ -11,7 +12,10 @@ type ShareData struct { FileName string } -func (h ShareData) Handler(w http.ResponseWriter, r *http.Request) { - tmpl := template.Must(template.ParseFS(lash.Templates, "share.html")) - tmpl.ExecuteTemplate(w, "share.html", h) +func (h *ShareData) Handler(w http.ResponseWriter, r *http.Request) { + tmpl := template.Must(template.ParseFS(lash.Templates, "templates/share.html")) + + if err := tmpl.ExecuteTemplate(w, "share.html", h); err != nil { + http.Error(w, "template render error: "+err.Error(), http.StatusInternalServerError) + } } diff --git a/lash.go b/lash.go index 9d29168..a019efa 100644 --- a/lash.go +++ b/lash.go @@ -3,13 +3,14 @@ package lash import ( "embed" - "github.com/google/uuid" + // "github.com/google/uuid" ) -//go:embed templates/* +//go:embed templates/*.html var Templates embed.FS //go:embed version var Version string -var Token string = uuid.New().String() +// var Token string = uuid.New().String() +var Token string = "foo" diff --git a/templates/share.html b/templates/share.html index c664116..52e7899 100644 --- a/templates/share.html +++ b/templates/share.html @@ -7,19 +7,13 @@ - -
- - -
-