From f4a348b00fc492ce4ea6a8f9055def006e951018 Mon Sep 17 00:00:00 2001 From: HeshamTB Date: Wed, 13 Sep 2023 14:52:57 +0300 Subject: [PATCH] feat: serve robots.txt, subtitle --- bindata.go | 5 ++++- main.go | 13 +++++++++++++ static/robots.txt | 1 + templates/download.html | 7 ++++++- 4 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 static/robots.txt diff --git a/bindata.go b/bindata.go index 88ed89d..4b246f6 100644 --- a/bindata.go +++ b/bindata.go @@ -5,9 +5,12 @@ import "embed" //go:embed templates/* var TemplatesFS embed.FS -//go:embed static/css/* +//go:embed static/css/* var PublicFS embed.FS //go:embed assets/* var AssetsFS embed.FS +//go:embed static/robots.txt +var RobotsFS embed.FS + diff --git a/main.go b/main.go index 05bcdc7..f199b95 100644 --- a/main.go +++ b/main.go @@ -135,6 +135,19 @@ func main() { handler.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.FS(PublicFS)))) handler.Handle("/assets/", http.FileServer(http.FS(AssetsFS))) + handler.HandleFunc( + "/robots.txt", + func(w http.ResponseWriter, r *http.Request) { + robotsFile, err := RobotsFS.ReadFile("static/robots.txt") + if err != nil { + log.Println(err.Error()) + w.WriteHeader(500) + return + } + w.Write(robotsFile) + }, + ) + handler.HandleFunc( "/download", func(w http.ResponseWriter, r *http.Request) { diff --git a/static/robots.txt b/static/robots.txt new file mode 100644 index 0000000..2370031 --- /dev/null +++ b/static/robots.txt @@ -0,0 +1 @@ +# Go carzy diff --git a/templates/download.html b/templates/download.html index ee355d5..d410022 100644 --- a/templates/download.html +++ b/templates/download.html @@ -11,7 +11,12 @@ Viddle your fiddle
-

Viddle your fiddle

+
+

+ Viddle your fiddle +

Grab your videos for safe keeping!

+ +