fix(static) serving assets on compilated build
This commit is contained in:
7
index.go
7
index.go
@@ -6,6 +6,7 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"html/template"
|
"html/template"
|
||||||
|
"io/fs"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
@@ -22,6 +23,9 @@ import (
|
|||||||
//go:embed templates/*
|
//go:embed templates/*
|
||||||
var templatesFS embed.FS
|
var templatesFS embed.FS
|
||||||
|
|
||||||
|
//go:embed static/*
|
||||||
|
var staticFS embed.FS
|
||||||
|
|
||||||
type Link struct {
|
type Link struct {
|
||||||
ID string
|
ID string
|
||||||
OriginalURL string
|
OriginalURL string
|
||||||
@@ -87,7 +91,8 @@ func initGithubOAuth() *oauth2.Config {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (app *App) SetupRoutes() {
|
func (app *App) SetupRoutes() {
|
||||||
app.Router.Static("/static", "./static")
|
staticContent, _ := fs.Sub(staticFS, "static")
|
||||||
|
app.Router.StaticFS("/static", http.FS(staticContent))
|
||||||
app.Router.GET("/", app.homePage)
|
app.Router.GET("/", app.homePage)
|
||||||
app.Router.POST("/", app.shortenURL)
|
app.Router.POST("/", app.shortenURL)
|
||||||
app.Router.GET("/login", app.loginGithub)
|
app.Router.GET("/login", app.loginGithub)
|
||||||
|
|||||||
Reference in New Issue
Block a user