http

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HeaderAuthorization string = "Authorization"
	HeaderDebugID       string = "X-Debug-ID"
	HeaderHMACSignature string = "X-Signature"
	HeaderDateRequest   string = "X-Date"
)

Variables

This section is empty.

Functions

func ConstructErrorResponseData

func ConstructErrorResponseData(debugID string, startProcessingTime time.Time, message string) map[string]interface{}

func ConstructStdResponseData

func ConstructStdResponseData(debugID string, startProcessingTime time.Time, data interface{}, message string) map[string]interface{}

func Get

func Get(ctx context.Context, req Request) (respBody []byte, respCode int, err error)

func GetDebugIDFromRequest

func GetDebugIDFromRequest(r *http.Request) string

GetDebugIDFromRequest get from request header

func GetMockUserAgent

func GetMockUserAgent() string

GetMockUserAgent returns a random mock user-agent

func Post

func Post(ctx context.Context, req Request) (respBody []byte, respCode int, err error)

Types

type API

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

func NewResponder

func NewResponder(w http.ResponseWriter, r *http.Request) (API, context.Context)

func NewResponderWithContext

func NewResponderWithContext(ctx context.Context, w http.ResponseWriter, r *http.Request) (API, context.Context)

func (API) BadRequestResponse

func (m API) BadRequestResponse(err error) error

func (API) ErrorResponse

func (m API) ErrorResponse(err error) error

func (API) ErrorResponseWithCustomData

func (m API) ErrorResponseWithCustomData(err error, data interface{}) error

func (API) ErrorResponseWithReqData

func (m API) ErrorResponseWithReqData(err error, data interface{}) error

func (API) GetDebugID

func (m API) GetDebugID() string

func (API) RawResponse

func (m API) RawResponse(statusCode int, message string, data interface{}) error

func (API) SuccessResponse

func (m API) SuccessResponse(data interface{}) error

func (API) SuccessResponseWithMessage

func (m API) SuccessResponseWithMessage(data interface{}, message string) error

func (API) UnathorizedResponse

func (m API) UnathorizedResponse(err error) error

func (API) UnathorizedResponseWithReqData

func (m API) UnathorizedResponseWithReqData(err error, data interface{}) error

type Request

type Request struct {
	URL           string
	Path          string
	Headers       map[string]string
	URLParams     map[string]string
	BodyParams    interface{}
	Timeout       time.Duration
	SkipErrorCode []int
}

Jump to

Keyboard shortcuts

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