From 363c3b6c96d5b3f4b4965b93c85d7c02cedff1de Mon Sep 17 00:00:00 2001 From: vxclutch Date: Thu, 28 May 2026 07:55:10 -0400 Subject: [PATCH] maint: comment source code --- TODO | 1 - cmd/lash/main.go | 1 + internal/app/routes.go | 2 +- internal/handlers/file.go | 1 + internal/handlers/share.go | 1 + lash.go | 1 + 6 files changed, 5 insertions(+), 2 deletions(-) diff --git a/TODO b/TODO index 49e8f3c..d50c361 100644 --- a/TODO +++ b/TODO @@ -1,5 +1,4 @@ maint: clean up source code -maint: comment source code maint: document more feat: improve flags feat: replace uuid dep with custom id generator diff --git a/cmd/lash/main.go b/cmd/lash/main.go index b2ccab9..990f0d4 100644 --- a/cmd/lash/main.go +++ b/cmd/lash/main.go @@ -23,6 +23,7 @@ func main() { srv := app.New() + // TODO(vxc): Make this more portable errx.Log("Your token is \033[1;92m%s\033[0m", lash.Token) errx.Log("starting server at http://0.0.0.0:%d", *port) diff --git a/internal/app/routes.go b/internal/app/routes.go index 264d28d..41858d8 100644 --- a/internal/app/routes.go +++ b/internal/app/routes.go @@ -22,7 +22,7 @@ func New() http.Handler { } share := handlers.ShareData{ - Version: lash.Version, + Version: lash.Version, } file := handlers.FileData{ diff --git a/internal/handlers/file.go b/internal/handlers/file.go index e2a0236..07ce2c8 100644 --- a/internal/handlers/file.go +++ b/internal/handlers/file.go @@ -32,6 +32,7 @@ func (h FileData) APIHandler(w http.ResponseWriter, r *http.Request) { return } + // Send the file over as a stream of bytes w.Header().Set("Content-Disposition", fmt.Sprintf("attachment; filename=%s", h.FileName)) w.Header().Set("Content-Type", "application/octet-stream") w.Header().Set("Content-Length", strconv.Itoa(len(h.Contents))) diff --git a/internal/handlers/share.go b/internal/handlers/share.go index ec11449..5a9fc94 100644 --- a/internal/handlers/share.go +++ b/internal/handlers/share.go @@ -13,6 +13,7 @@ type ShareData struct { } func (h *ShareData) Handler(w http.ResponseWriter, r *http.Request) { + // Although `Must` can fail since `Templates` is embeded these files will always exist. tmpl := template.Must(template.ParseFS(lash.Templates, "templates/share.html")) if err := tmpl.ExecuteTemplate(w, "share.html", h); err != nil { diff --git a/lash.go b/lash.go index 0931b3b..9b763bc 100644 --- a/lash.go +++ b/lash.go @@ -12,4 +12,5 @@ var Templates embed.FS //go:embed version var Version string +// TODO(vxc): Replace this with custom token generator var Token string = uuid.New().String()