Add support for serving local files on 'listen' mode
Some checks failed
/ basic (push) Failing after 22s

This commit is contained in:
天クマ 2026-05-16 12:29:31 -03:00
commit 7627a5bc1c

View file

@ -41,6 +41,8 @@ is up to you, eg. Nginx, Apache, or even a simple Go server.
token := viper.GetString("token") token := viper.GetString("token")
dir := viper.GetString("dir") dir := viper.GetString("dir")
branch := viper.GetString("branch") branch := viper.GetString("branch")
notFound := viper.GetString("notfound")
files := viper.GetString("files")
if bind == "" || server == "" || user == "" || token == "" || branch == "" || dir == "" { if bind == "" || server == "" || user == "" || token == "" || branch == "" || dir == "" {
fmt.Println("bind, server, user, token, branch and dir are required") fmt.Println("bind, server, user, token, branch and dir are required")
fmt.Println("dumping flags:") fmt.Println("dumping flags:")
@ -50,6 +52,8 @@ is up to you, eg. Nginx, Apache, or even a simple Go server.
fmt.Println(" token: ", token) fmt.Println(" token: ", token)
fmt.Println(" branch: ", branch) fmt.Println(" branch: ", branch)
fmt.Println(" dir: ", dir) fmt.Println(" dir: ", dir)
fmt.Println(" notfound: ", notFound)
fmt.Println(" files: ", files)
return return
} }
serverUrl, err := url.Parse(server) serverUrl, err := url.Parse(server)
@ -60,9 +64,11 @@ is up to you, eg. Nginx, Apache, or even a simple Go server.
cfg := &lib.WebhookCFG{ cfg := &lib.WebhookCFG{
Forgejo: lib.Forgejo{ Forgejo: lib.Forgejo{
Server: *serverUrl, Server: *serverUrl,
Token: token, Token: token,
Branch: branch, Branch: branch,
NotFound: notFound,
Files: files,
}, },
GitDir: filepath.Join(dir, "git"), GitDir: filepath.Join(dir, "git"),
PageDir: filepath.Join(dir, "pages"), PageDir: filepath.Join(dir, "pages"),
@ -103,4 +109,6 @@ func init() {
f.StringP("token", "k", "", "Forgejo api token or password") f.StringP("token", "k", "", "Forgejo api token or password")
f.StringP("branch", "b", "static-pages", "branch to use") f.StringP("branch", "b", "static-pages", "branch to use")
f.StringP("dir", "d", "", "directory to store data, must be writable") f.StringP("dir", "d", "", "directory to store data, must be writable")
f.StringP("notfound", "n", "", "path to custom 404.html file")
f.StringP("files", "f", "", "path for files to be served ")
} }