Skip to content

Commit

Permalink
server static asset
Browse files Browse the repository at this point in the history
  • Loading branch information
sxc committed Aug 15, 2023
1 parent 445cec0 commit 3cd333f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions cmd/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,9 @@ func main() {
})
})

assetsHandler := http.FileServer(http.Dir("assets"))
r.Get("/assets/*", http.StripPrefix("/assets", assetsHandler).ServeHTTP)

r.NotFound(func(w http.ResponseWriter, r *http.Request) {
http.Error(w, "Not Found", http.StatusNotFound)
})
Expand Down
2 changes: 1 addition & 1 deletion templates/tailwind.gohtml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<script src="https://cdn.tailwindcss.com"></script>
<link rel="stylesheet" href="/assets/styles.css" />
<title>My Awesome Site</title>
</head>
<body class="min-h-screen bg-gray-100">
Expand Down

0 comments on commit 3cd333f

Please sign in to comment.