utils

package
v1.2.7 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthedRequest

type AuthedRequest struct {
	AuthToken string
	BaseURL   string
	Path      string
	Body      []byte
}

AuthedRequest represents an authenticated HTTP request.

func NewRequestBuilder

func NewRequestBuilder(authToken string) *AuthedRequest

NewRequestBuilder initializes a new RequestBuilder.

func (*AuthedRequest) Build

func (rb *AuthedRequest) Build(ctx context.Context) (*http.Request, error)

Build constructs the HTTP request [Method:Post].

func (*AuthedRequest) BuildGet added in v0.1.1

func (rb *AuthedRequest) BuildGet(ctx context.Context) (*http.Request, error)

BuildGet constructs the HTTP request [Method:Get].

func (*AuthedRequest) BuildStream added in v0.1.1

func (rb *AuthedRequest) BuildStream(ctx context.Context) (*http.Request, error)

BuildStream constructs the HTTP request for a streaming response [Method:Post].

func (*AuthedRequest) SetBaseURL

func (rb *AuthedRequest) SetBaseURL(BaseURL string) *AuthedRequest

SetBaseURL sets the base URL for the request.

func (*AuthedRequest) SetBodyFromStruct

func (rb *AuthedRequest) SetBodyFromStruct(data interface{}) *AuthedRequest

SetBodyFromStruct sets the request body from a struct, marshaling it to JSON. transform interface to ChatCompletionRequest

func (*AuthedRequest) SetPath

func (rb *AuthedRequest) SetPath(path string) *AuthedRequest

SetPath sets the path for the request.

type AuthedRequestBuilder

type AuthedRequestBuilder interface {
	SetBaseURL(string) *AuthedRequest
	SetPath(string) *AuthedRequest
	SetBodyFromStruct(interface{}) *AuthedRequest
	Build(context.Context) (*http.Request, error)
}

AuthedRequestBuilder is an interface for building authenticated requests.

Jump to

Keyboard shortcuts

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