feat: initial commit

This commit is contained in:
2025-06-10 21:09:58 +02:00
commit 1fb753469e
84 changed files with 3912 additions and 0 deletions

View File

@ -0,0 +1,28 @@
package context
import (
"context"
"net/url"
"github.com/pkg/errors"
)
const keyBaseURL = "baseURL"
func BaseURL(ctx context.Context) *url.URL {
rawBaseURL, ok := ctx.Value(keyBaseURL).(string)
if !ok {
panic(errors.New("no base url in context"))
}
baseURL, err := url.Parse(rawBaseURL)
if err != nil {
panic(errors.WithStack(err))
}
return baseURL
}
func SetBaseURL(ctx context.Context, baseURL string) context.Context {
return context.WithValue(ctx, keyBaseURL, baseURL)
}