feat: gitea client

This commit is contained in:
2026-02-12 20:58:55 +01:00
parent 8583ab48ce
commit db1ecd1e64
12 changed files with 301 additions and 233 deletions

View File

@@ -0,0 +1,31 @@
package baseadapter
import (
"fmt"
"io"
"net/http"
"net/url"
)
type Rest struct {
baseURL string
bearerToken string
}
func (b *Rest) createRequest(method string, body io.Reader, path ...string) (r *http.Request, err error) {
target, err := url.JoinPath(b.baseURL, path...)
if err != nil {
err = fmt.Errorf("can not parse path: %w", err)
return
}
req, err := http.NewRequest(method, target, body)
if err != nil {
return nil, err
}
if b.bearerToken != "" {
req.Header.Set("Authorization", "Bearer "+b.bearerToken)
}
return req, nil
}