mirror of
https://github.com/mxpv/podsync.git
synced 2024-05-11 05:55:04 +00:00
Implement static files handling
This commit is contained in:
@@ -34,6 +34,7 @@ func ReadConfiguration() (cfg *AppConfig, err error) {
|
||||
"patreonClientId": "PATREON_CLIENT_ID",
|
||||
"patreonSecret": "PATREON_SECRET",
|
||||
"postgresConnectionUrl": "POSTGRES_CONNECTION_URL",
|
||||
"redisUrl": "REDIS_CONNECTION_URL",
|
||||
}
|
||||
|
||||
for k, v := range envmap {
|
||||
|
||||
@@ -2,7 +2,10 @@ package server
|
||||
|
||||
import (
|
||||
"context"
|
||||
"go/build"
|
||||
"log"
|
||||
"net/http"
|
||||
"path"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
itunes "github.com/mxpv/podcast"
|
||||
@@ -20,6 +23,20 @@ func MakeHandlers(feed feed) http.Handler {
|
||||
r := gin.New()
|
||||
r.Use(gin.Recovery())
|
||||
|
||||
// Static files + HTML
|
||||
|
||||
rootDir := path.Join(build.Default.GOPATH, "src/github.com/mxpv/podsync")
|
||||
log.Printf("Using root directory: %s", rootDir)
|
||||
|
||||
r.Static("/assets", path.Join(rootDir, "assets"))
|
||||
r.LoadHTMLGlob(path.Join(rootDir, "templates/*.html"))
|
||||
|
||||
r.GET("/", func(c *gin.Context) {
|
||||
c.HTML(http.StatusOK, "index.html", gin.H{"title": "Index page"})
|
||||
})
|
||||
|
||||
// REST API
|
||||
|
||||
r.GET("/ping", func(c *gin.Context) {
|
||||
c.String(http.StatusOK, "ok")
|
||||
})
|
||||
|
||||
5
templates/index.html
Normal file
5
templates/index.html
Normal file
@@ -0,0 +1,5 @@
|
||||
<html>
|
||||
<h1>
|
||||
{{ .title }}
|
||||
</h1>
|
||||
</html>
|
||||
Reference in New Issue
Block a user