mirror of
https://codeberg.org/Codeberg/pages-server.git
synced 2024-11-05 14:07:01 +00:00
make it conf via arg or env
This commit is contained in:
parent
aa83b307db
commit
b1b23ce2ec
5 changed files with 17 additions and 5 deletions
11
cmd/flags.go
11
cmd/flags.go
|
@ -69,6 +69,17 @@ var ServeFlags = []cli.Flag{
|
|||
// TODO: desc
|
||||
EnvVars: []string{"ENABLE_HTTP_SERVER"},
|
||||
},
|
||||
// Server Options
|
||||
&cli.BoolFlag{
|
||||
Name: "enable-lfs-support",
|
||||
Usage: "enable lfs support, require gitea v1.17.0 as backend",
|
||||
EnvVars: []string{"ENABLE_LFS_SUPPORT"},
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
Name: "enable-symlink-support",
|
||||
Usage: "follow symlinks if enabled, require gitea v1.18.0 as backend",
|
||||
EnvVars: []string{"ENABLE_SYMLINK_SUPPORT"},
|
||||
},
|
||||
|
||||
// ACME
|
||||
&cli.StringFlag{
|
||||
|
|
|
@ -82,7 +82,7 @@ func Serve(ctx *cli.Context) error {
|
|||
// TODO: make this an MRU cache with a size limit
|
||||
fileResponseCache := cache.NewKeyValueCache()
|
||||
|
||||
giteaClient, err := gitea.NewClient(giteaRoot, giteaAPIToken)
|
||||
giteaClient, err := gitea.NewClient(giteaRoot, giteaAPIToken, ctx.Bool("enable-symlink-support"), ctx.Bool("enable-lfs-support"))
|
||||
if err != nil {
|
||||
return fmt.Errorf("could not create new gitea client: %v", err)
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@ import (
|
|||
"io"
|
||||
"net/http"
|
||||
"net/http/cookiejar"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/rs/zerolog/log"
|
||||
|
|
|
@ -44,7 +44,7 @@ func joinURL(baseURL string, paths ...string) string {
|
|||
return baseURL + "/" + strings.Join(p, "/")
|
||||
}
|
||||
|
||||
func NewClient(giteaRoot, giteaAPIToken string) (*Client, error) {
|
||||
func NewClient(giteaRoot, giteaAPIToken string, followSymlinks, supportLFS bool) (*Client, error) {
|
||||
rootURL, err := url.Parse(giteaRoot)
|
||||
giteaRoot = strings.Trim(rootURL.String(), "/")
|
||||
|
||||
|
@ -55,8 +55,8 @@ func NewClient(giteaRoot, giteaAPIToken string) (*Client, error) {
|
|||
contentTimeout: 10 * time.Second,
|
||||
fastClient: getFastHTTPClient(),
|
||||
|
||||
followSymlinks: true,
|
||||
supportLFS: true,
|
||||
followSymlinks: followSymlinks,
|
||||
supportLFS: supportLFS,
|
||||
}, err
|
||||
}
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ import (
|
|||
|
||||
func TestHandlerPerformance(t *testing.T) {
|
||||
giteaRoot := "https://codeberg.org"
|
||||
giteaClient, _ := gitea.NewClient(giteaRoot, "")
|
||||
giteaClient, _ := gitea.NewClient(giteaRoot, "", false, false)
|
||||
testHandler := Handler(
|
||||
[]byte("codeberg.page"), []byte("raw.codeberg.org"),
|
||||
giteaClient,
|
||||
|
|
Loading…
Reference in a new issue