holyapi

package
v1.0.10 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 7, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package holyapi provides client for interacting with other Holyheld services over HTTP

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractUserAgent

func ExtractUserAgent(ctx context.Context) string

func ExtractVia

func ExtractVia(ctx context.Context) string

func ProvideUserAgent

func ProvideUserAgent(ua string) func(http.Handler) http.Handler

func ProvideVia

func ProvideVia(pseudonym string) func(http.Handler) http.Handler

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(baseURL holder.Holder[string], opts ...Option) *Client

func (*Client) Request

func (c *Client) Request(
	ctx context.Context,
	method string,
	path string,
	header http.Header,
	body any,
	successResponse any,
) (int, error)

func (*Client) RequestWithOptions added in v1.0.8

func (c *Client) RequestWithOptions(
	ctx context.Context,
	method string,
	path string,
	body any,
	successResponse any,
	opts ...rest.RequestOption,
) (int, error)

func (*Client) RequestWithRetry

func (c *Client) RequestWithRetry(
	ctx context.Context,
	method string,
	path string,
	header http.Header,
	body any,
	successResponse any,
	retries int,
	checkRetry retryablehttp.CheckRetry,
) (int, error)

type NonContractResponseError

type NonContractResponseError struct {
	// contains filtered or unexported fields
}

func NewNonContractResponseError

func NewNonContractResponseError(status int, cause error) *NonContractResponseError

func (*NonContractResponseError) Error

func (e *NonContractResponseError) Error() string

func (*NonContractResponseError) Is

func (e *NonContractResponseError) Is(target error) bool

func (*NonContractResponseError) LogValue

func (e *NonContractResponseError) LogValue() slog.Value

func (*NonContractResponseError) Unwrap

func (e *NonContractResponseError) Unwrap() error

type Option added in v1.0.8

type Option func(*Client)

func WithClient added in v1.0.8

func WithClient(c *http.Client) Option

type ResponseError

type ResponseError struct {
	Status           Status          `json:"status"`
	ErrorDescription string          `json:"error"`
	ErrorCode        string          `json:"errorCode"`
	Payload          json.RawMessage `json:"payload,omitempty"`
	Meta             ResponseMeta    `json:"-"`
}

func (*ResponseError) Error

func (r *ResponseError) Error() string

func (*ResponseError) LogValue

func (r *ResponseError) LogValue() slog.Value

type ResponseMeta

type ResponseMeta struct {
	URL    string `json:"url"`
	Method string `json:"method"`
	Status int    `json:"status"`
}

type ResponseSuccess

type ResponseSuccess struct {
	Status  Status `json:"status"`
	Payload any    `json:"payload,omitempty"`
}

type Status

type Status string
const (
	StatusOK    Status = "ok"
	StatusError Status = "error"
)

type UnexpectedError

type UnexpectedError struct {
	// contains filtered or unexported fields
}

func NewUnexpectedError

func NewUnexpectedError(status int, cause *ResponseError) *UnexpectedError

func (*UnexpectedError) Error

func (e *UnexpectedError) Error() string

func (*UnexpectedError) Is

func (e *UnexpectedError) Is(target error) bool

func (*UnexpectedError) LogValue

func (e *UnexpectedError) LogValue() slog.Value

func (*UnexpectedError) Unwrap

func (e *UnexpectedError) Unwrap() error

type UnexpectedStatusError

type UnexpectedStatusError struct {
	// contains filtered or unexported fields
}

func NewUnexpectedStatusError

func NewUnexpectedStatusError(status int) *UnexpectedStatusError

func (*UnexpectedStatusError) Error

func (e *UnexpectedStatusError) Error() string

func (*UnexpectedStatusError) LogValue

func (e *UnexpectedStatusError) LogValue() slog.Value

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL