Skip to content

Commit

Permalink
feat(*): add favicon and robots router and template
Browse files Browse the repository at this point in the history
  • Loading branch information
adhocore committed Apr 2, 2021
1 parent 4af8e30 commit f24ea69
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 0 deletions.
12 changes: 12 additions & 0 deletions controller/frontend.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,18 @@ func Index(res http.ResponseWriter, req *http.Request) {
http.ServeFile(res, req, "tmpl/home.html")
}

// Favicon is the controller for favicon.ico
// It responds to `GET /favicon.ico` and does not require auth token.
func Favicon(res http.ResponseWriter, req *http.Request) {
http.ServeFile(res, req, "tmpl/u.png")
}

// Robots is the controller for robots.txt
// It responds to `GET /favicon.ico` and does not require auth token.
func Robots(res http.ResponseWriter, req *http.Request) {
http.ServeFile(res, req, "tmpl/robots.txt")
}

// Status is the controller for health/status check
// It responds to `GET /status` and does not require auth token.
func Status(res http.ResponseWriter, _ *http.Request) {
Expand Down
2 changes: 2 additions & 0 deletions router/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import (

var routes = map[string]http.HandlerFunc{
"GET /": controller.Index,
"GET /favicon.ico": controller.Favicon,
"GET /robots.txt": controller.Robots,
"GET /status": controller.Status,
"POST /api/urls": controller.CreateShortURL,
"GET /api/admin/urls": controller.ListURLs,
Expand Down
2 changes: 2 additions & 0 deletions tmpl/robots.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
User-agent: *
Disallow: /*/
Binary file added tmpl/u.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit f24ea69

Please sign in to comment.