httprequest

package
v0.0.0-...-35aec58 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2024 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 Builder

type Builder struct {
	HttpRequest *http.Request
	Error       error
}

func (*Builder) Build

func (i *Builder) Build() (*http.Request, error)

Build returns the http request and error.

func (*Builder) New

func (i *Builder) New(ctx context.Context, method Method, url string) *Builder

New creates a new http request with the given method and url.

func (*Builder) WithAuth

func (i *Builder) WithAuth(auth string) *Builder

WithAuth sets the request `Authorization` header .

func (*Builder) WithBody

func (i *Builder) WithBody(body any) *Builder

WithBody sets the request body.

func (*Builder) WithHeaders

func (i *Builder) WithHeaders(headers map[string]string) *Builder

WithHeaders sets the request headers.

type ContentType

type ContentType string
const (
	ApplicationJson ContentType = "application/json"
)

type HeaderKey

type HeaderKey string
const (
	RequestId      HeaderKey = "X-Request-ID"
	ContentTypeKey HeaderKey = "Content-Type"
	Authorization  HeaderKey = "Authorization"
)

type Method

type Method string
const (
	Options Method = "OPTIONS"
	Get     Method = "GET"
	Head    Method = "HEAD"
	Post    Method = "POST"
	Put     Method = "PUT"
	Delete  Method = "DELETE"
	Trace   Method = "TRACE"
	Connect Method = "CONNECT"
)

Jump to

Keyboard shortcuts

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