parcel

package module
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2023 License: Apache-2.0 Imports: 13 Imported by: 0

README

parcel

HTTP binding and rendering library. Includes an enhanced HTTP client

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

func NewClient

func NewClient(baseUrl string, headerResolvers ...HeaderResolver) *Client

func (Client) NewJsonRequest

func (client Client) NewJsonRequest(ctx context.Context, data any, method, pathFmt string, args ...any) *Request

func (Client) NewRequest

func (client Client) NewRequest(ctx context.Context, method, pathFmt string, args ...any) *Request

type Handler

type Handler interface {
	Reader

	Json() Writer
}

func NewHandler

func NewHandler(useValidator bool) Handler

type HeaderResolver

type HeaderResolver func(ctx context.Context) http.Header

type HttpData

type HttpData interface {
	Header() http.Header
	Body() io.ReadCloser
}

type ReadWriter

type ReadWriter interface {
	Reader
	Writer
}

type Reader

type Reader interface {
	ReadRequest(r *http.Request, target any) error
	ReadResponse(r *http.Response, target any) error
}

type Request

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

func (*Request) AddQueryBool

func (r *Request) AddQueryBool(key string, val nullable.NBool)

func (*Request) AddQueryString

func (r *Request) AddQueryString(key string, val nullable.NString)

func (*Request) AddQueryTime

func (r *Request) AddQueryTime(key string, val nullable.NTime)

func (*Request) Do

func (r *Request) Do() *Response

func (*Request) Header

func (r *Request) Header() http.Header

type Response

type Response struct {
	HttpResponse *http.Response
	// contains filtered or unexported fields
}

func (Response) Read

func (r Response) Read(data any, validRepsonses ...int) error

func (Response) Validate

func (r Response) Validate(validRepsonses ...int) error

type Writer

type Writer interface {
	Write(w http.ResponseWriter, status int, data any) error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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