client

package
v0.0.0-...-5e385dd Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIError

type APIError struct {
	StatusCode int
	Message    string
}

APIError represents an API error.

func (*APIError) Error

func (e *APIError) Error() string

type Client

type Client struct {

	// Session management
	Username string
	// contains filtered or unexported fields
}

Client represents a Hydra API client.

func NewClient

func NewClient(baseURL string, opts ...Option) (*Client, error)

NewClient creates a new Hydra API client.

func (*Client) BaseURL

func (c *Client) BaseURL() string

BaseURL returns the base URL of the client.

func (*Client) DoRequest

func (c *Client) DoRequest(ctx context.Context, method, path string, body interface{}, v interface{}) error

DoRequest performs an HTTP request.

func (*Client) GetUsername

func (c *Client) GetUsername() string

GetUsername returns the username of the authenticated user.

func (*Client) IsAuthenticated

func (c *Client) IsAuthenticated() bool

IsAuthenticated returns true if the client has an active session.

func (*Client) Logout

func (c *Client) Logout()

Logout clears the session.

func (*Client) SetBaseURL

func (c *Client) SetBaseURL(baseURL string) error

SetBaseURL updates the base URL of the client.

type Option

type Option func(*Client)

Option represents a client configuration option.

func WithHTTPClient

func WithHTTPClient(httpClient *http.Client) Option

WithHTTPClient sets a custom HTTP client.

func WithTimeout

func WithTimeout(timeout time.Duration) Option

WithTimeout sets the HTTP client timeout.

func WithUserAgent

func WithUserAgent(userAgent string) Option

WithUserAgent sets a custom user agent.

Jump to

Keyboard shortcuts

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