Add support for serving files when API doesn't return good result.
Some checks failed
/ basic (push) Failing after 19s

This commit is contained in:
天クマ 2026-05-15 18:00:59 -03:00
commit 486cbfb6b4
6 changed files with 352 additions and 18 deletions

View file

@ -37,6 +37,8 @@ cache/protection layer like Cloudflare in front of the server.
server := viper.GetString("server")
token := viper.GetString("token")
branch := viper.GetString("branch")
notFound := viper.GetString("notfound")
files := viper.GetString("files")
if bind == "" || server == "" || token == "" || branch == "" {
fmt.Println("bind, server token and branch are required")
fmt.Println("dumping flags:")
@ -44,6 +46,8 @@ cache/protection layer like Cloudflare in front of the server.
fmt.Println(" server: ", server)
fmt.Println(" token: ", token)
fmt.Println(" branch: ", branch)
fmt.Println(" notfound: ", notFound)
fmt.Println(" files: ", files)
return
}
serverUrl, err := url.Parse(server)
@ -52,9 +56,11 @@ cache/protection layer like Cloudflare in front of the server.
return
}
f := &lib.Forgejo{
Server: *serverUrl,
Token: token,
Branch: branch,
Server: *serverUrl,
Token: token,
Branch: branch,
NotFound: notFound,
Files: files,
}
s, err := lib.UseAPI(bind, viper.GetString("well-known"), f)
@ -85,4 +91,6 @@ func init() {
f.StringP("token", "k", "", "Forgejo api token")
f.StringP("branch", "b", "static-pages", "branch to use")
f.StringP("well-known", "w", "", "well-known path, used by LetsEncrypt")
f.StringP("notfound", "n", "", "path to custom 404.html file")
f.StringP("files", "f", "", "path for files to be served ")
}