Merge branch 'main' into feature/lru-cache

This commit is contained in:
crapStone 2024-05-26 16:52:50 +00:00
commit 044c61dbb6
15 changed files with 121 additions and 67 deletions

View file

@ -57,12 +57,13 @@ type Client struct {
defaultMimeType string
}
func NewClient(cfg config.GiteaConfig, respCache cache.ICache) (*Client, error) {
rootURL, err := url.Parse(cfg.Root)
func NewClient(cfg config.ForgeConfig, respCache cache.ICache) (*Client, error) {
// url.Parse returns valid on almost anything...
rootURL, err := url.ParseRequestURI(cfg.Root)
if err != nil {
return nil, err
return nil, fmt.Errorf("invalid forgejo/gitea root url: %w", err)
}
giteaRoot := strings.Trim(rootURL.String(), "/")
giteaRoot := strings.TrimSuffix(rootURL.String(), "/")
stdClient := http.Client{Timeout: 10 * time.Second}

View file

@ -13,7 +13,7 @@ import (
)
func TestHandlerPerformance(t *testing.T) {
cfg := config.GiteaConfig{
cfg := config.ForgeConfig{
Root: "https://codeberg.org",
Token: "",
LFSEnabled: false,

View file

@ -74,7 +74,7 @@ func Serve(ctx *cli.Context) error {
// clientResponseCache stores responses from the Gitea server
clientResponseCache := cache.NewInMemoryCache()
giteaClient, err := gitea.NewClient(cfg.Gitea, clientResponseCache)
giteaClient, err := gitea.NewClient(cfg.Forge, clientResponseCache)
if err != nil {
return fmt.Errorf("could not create new gitea client: %v", err)
}