requester

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: May 26, 2025 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

Module provides the requester module dependencies

Functions

This section is empty.

Types

type AuthManager

type AuthManager interface {
	ApplyAuth(req *http.Request) error
}

AuthManager handles request authentication

type FileUploadConfig

type FileUploadConfig struct {
	FieldName    string   `json:"field_name"`
	AllowedTypes []string `json:"allowed_types"`
	MaxSize      int64    `json:"max_size"`
}

FileUploadConfig holds configuration for file uploads

type HTTPAuthManager

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

HTTPAuthManager implements the AuthManager interface

func NewHTTPAuthManager

func NewHTTPAuthManager(serviceConfig *config.EndpointConfig) *HTTPAuthManager

NewHTTPAuthManager creates a new HTTPAuthManager

func (*HTTPAuthManager) ApplyAuth

func (a *HTTPAuthManager) ApplyAuth(req *http.Request) error

ApplyAuth adds authentication to the request

type HTTPRequestBuilder

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

HTTPRequestBuilder implements the RequestBuilder interface

func NewHTTPRequestBuilder

func NewHTTPRequestBuilder(params HTTPRequestBuilderParams) *HTTPRequestBuilder

NewHTTPRequestBuilder creates a new HTTPRequestBuilder

func (*HTTPRequestBuilder) BuildRequest

func (b *HTTPRequestBuilder) BuildRequest(ctx context.Context, params map[string]interface{}) (*Request, error)

BuildRequest builds a request from a route name and parameters

type HTTPRequestBuilderParams

type HTTPRequestBuilderParams struct {
	fx.In
	EndpointConfig *config.EndpointConfig
	AuthManager    AuthManager
	RouteConfig    *RouteConfig
}

HTTPRequestBuilderParams holds the parameters for creating an HTTPRequestBuilder

type HTTPRequester

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

HTTPRequester handles both request building and execution

func NewHTTPRequester

func NewHTTPRequester(params HTTPRequesterParams) *HTTPRequester

NewHTTPRequester creates a new HTTPRequester with default configuration

func (*HTTPRequester) BuildRouteExecutor

func (r *HTTPRequester) BuildRouteExecutor(config *RouteConfig) (RouteExecutor, error)

BuildRouteExecutor creates a function that can execute requests for a specific route

func (*HTTPRequester) SetTimeout

func (r *HTTPRequester) SetTimeout(timeout time.Duration)

SetTimeout sets the timeout for the HTTP client

type HTTPRequesterParams

type HTTPRequesterParams struct {
	fx.In

	ServiceConfig *config.EndpointConfig
	AuthManager   AuthManager
}

type MethodConfig

type MethodConfig struct {
	// For GET requests
	QueryParams []string `json:"query_params,omitempty"`

	// For multipart/form-data
	FormFields []string `json:"form_fields,omitempty"`

	// For file uploads
	FileUpload *FileUploadConfig `json:"file_upload,omitempty"`
}

MethodConfig holds method-specific configurations

type Request

type Request struct {
	URL         string
	Method      string
	Body        io.Reader
	Headers     map[string]string
	ContentType string
	HttpRequest *http.Request // The actual HTTP request
}

Request represents a fully built HTTP request

type RequestResult

type RequestResult struct {
	StatusCode int
	Body       []byte
	Headers    http.Header
	Error      error
}

RequestResult holds the result of a request

type Response

type Response struct {
	StatusCode int
	Body       []byte
	Headers    http.Header
	Error      error
}

Response represents an HTTP response

type RouteConfig

type RouteConfig struct {
	Path        string            `json:"path"`
	Method      string            `json:"method"`
	Description string            `json:"description,omitempty"`
	Headers     map[string]string `json:"headers"`
	Parameters  map[string]string `json:"parameters"`
	// Method specific configurations
	MethodConfig MethodConfig `json:"method_config"`
}

RouteConfig holds the configuration for a specific route

type RouteExecutor

type RouteExecutor func(ctx context.Context, params map[string]interface{}) (*Response, error)

RouteExecutor is a function that can execute a route with params

Jump to

Keyboard shortcuts

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