Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FileSource ¶
type FileSource struct {
// contains filtered or unexported fields
}
FileSource loads JSON files from one directory and keys them by filename.
func NewFileSource ¶
func NewFileSource(directory string) (*FileSource, error)
NewFileSource loads all .json files in directory. A missing directory is represented by an empty source.
func (*FileSource) Fetch ¶
func (s *FileSource) Fetch(_ context.Context, key string) (json.RawMessage, bool, error)
func (*FileSource) FetchAll ¶
func (s *FileSource) FetchAll(context.Context) (map[string]json.RawMessage, error)
type HTTPSource ¶
type HTTPSource[K comparable] struct { // contains filtered or unexported fields }
HTTPSource fetches keyed raw values over HTTP using caller-provided protocol functions.
func NewHTTPSource ¶
func NewHTTPSource[K comparable](client *http.Client, endpoint string, buildRequest RequestBuilder[K], decodeResponse ResponseDecoder[K]) (*HTTPSource[K], error)
NewHTTPSource builds a reusable HTTP source. Request construction and response decoding remain with the consuming data type.
func (*HTTPSource[K]) Fetch ¶
func (s *HTTPSource[K]) Fetch(ctx context.Context, key K) (json.RawMessage, bool, error)
type RequestBuilder ¶
type RequestBuilder[K comparable] func(ctx context.Context, endpoint *url.URL, key K) (*http.Request, error)
RequestBuilder creates a request for one source key.
type ResponseDecoder ¶
type ResponseDecoder[K comparable] func(key K, body []byte) (raw json.RawMessage, found bool, err error)
ResponseDecoder extracts one source value from a successful HTTP response.
Click to show internal directories.
Click to hide internal directories.