Documentation
¶
Overview ¶
Package api provides the HTTP client for the Life@USTC API.
Package api provides the HTTP client for the Life@USTC API.
typed.go bridges the generated OpenAPI client with the existing auth/token-refresh logic by injecting an authTransport into the standard http.Client used by the generated code.
Index ¶
- func Ctx() context.Context
- func DecodeResponseBody(body []byte, contentType string, fallbackToText bool) (any, error)
- func IsJSONContentType(contentType string) bool
- func ParseResponse[T any](resp *http.Response, err error) (any, error)
- func ReadResponse(resp *http.Response, err error) ([]byte, string, error)
- func ReadTypedResponse[T any](resp *http.Response, err error) (*T, error)
- type Client
- type TypedClient
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DecodeResponseBody ¶ added in v0.2.0
func IsJSONContentType ¶ added in v0.2.0
func ParseResponse ¶ added in v0.2.0
ParseResponse decodes the generated response model before adapting it for the shared table, JSON and jq presentation layer.
func ReadResponse ¶ added in v0.2.0
Types ¶
type Client ¶
Client wraps net/http with automatic auth header injection and token refresh.
func NewClientWithRefresh ¶ added in v0.2.0
func NewClientWithRefresh(server string, requireAuth bool, refresh refreshTokenFunc) (*Client, error)
NewClientWithRefresh creates a Client with a custom token refresh function. Pass nil for refresh to use the default auth.RefreshToken; this is intended for tests that want to inject a mock refresh without hitting the real server.
type TypedClient ¶ added in v0.2.0
TypedClient wraps the generated OpenAPI client with auth support.
func NewTypedClient ¶ added in v0.2.0
func NewTypedClient(server string, requireAuth bool) (*TypedClient, error)
NewTypedClient creates a TypedClient with auth, using the generated OpenAPI client.