Documentation ¶
Index ¶
- Constants
- func DTO[T any](response Response, v T) T
- func DTOorFail[T any](response Response, v T) (T, error)
- type AccessTokenAuth
- type AuthRoom
- type Connector
- type Context
- type ContextBuilder
- type FormURLEncodedBody
- type HTTPMethod
- type HTTPProtocol
- type Header
- type IAuth
- type IBodyParser
- type IContextBuilder
- type IDTOFactory
- type IHeader
- type IMapQuery
- type IQuery
- type IRoom
- type ISend
- type IUrlQuery
- type JsonBody
- type JsonDTOFactory
- type MultipartFormDataBody
- type MultipartFormDataDTOFactory
- type OptionConnector
- type OptionRequest
- func WithBody(bodyParser IBodyParser) OptionRequest
- func WithContextBuilder(contextBuilder IContextBuilder) OptionRequest
- func WithCookies(cookies ...*http.Cookie) OptionRequest
- func WithHeader(header IHeader) OptionRequest
- func WithMethod(method HTTPMethod) OptionRequest
- func WithQuery(query IQuery) OptionRequest
- type Query
- type Request
- type RequestDTO
- type Response
- func (r Response) DTO(v any) any
- func (r Response) DTOorFail(v any) error
- func (r Response) OK() bool
- func (r Response) RequestBody() map[string]any
- func (r Response) RequestBodyOrFail() (map[string]any, error)
- func (r Response) RequestDTO(v any) any
- func (r Response) RequestDTOorFail(v any) any
- func (r Response) ResponseBody() map[string]any
- func (r Response) ResponseBodyOrFail() (map[string]any, error)
- type Room
- type URI
- type XMLDTOFactory
Constants ¶
View Source
const (
ErrAuthRoomCanNotFoundKey = "authToken can not found in response"
)
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AccessTokenAuth ¶
type AccessTokenAuth struct{}
func (AccessTokenAuth) Apply ¶
func (a AccessTokenAuth) Apply(connector *Connector, response Response)
type Connector ¶
type Connector struct { Header IHeader // contains filtered or unexported fields }
func NewConnector ¶
func NewConnector(baseUrl string, opts ...OptionConnector) *Connector
type ContextBuilder ¶
type ContextBuilder struct {
// contains filtered or unexported fields
}
func NewContextBuilder ¶
func NewContextBuilder(timeout time.Duration) ContextBuilder
func (ContextBuilder) Build ¶
func (b ContextBuilder) Build() Context
type FormURLEncodedBody ¶
type FormURLEncodedBody struct {
// contains filtered or unexported fields
}
func (*FormURLEncodedBody) ContentType ¶ added in v1.2.0
func (f *FormURLEncodedBody) ContentType() string
func (*FormURLEncodedBody) Parse ¶
func (f *FormURLEncodedBody) Parse() *bytes.Buffer
type HTTPMethod ¶
type HTTPMethod string
const ( GET HTTPMethod = "GET" POST HTTPMethod = "POST" PUT HTTPMethod = "PUT" PATCH HTTPMethod = "PATCH" DELETE HTTPMethod = "DELETE" HEAD HTTPMethod = "HEAD" )
func (HTTPMethod) String ¶
func (s HTTPMethod) String() string
type HTTPProtocol ¶
type HTTPProtocol int
const ( Http HTTPProtocol = iota + 1 Https )
func (HTTPProtocol) String ¶
func (h HTTPProtocol) String() string
type Header ¶
type Header struct {
// contains filtered or unexported fields
}
func (*Header) Properties ¶
type IAuth ¶
func NewAccessTokenAuth ¶ added in v1.0.1
func NewAccessTokenAuth() IAuth
type IBodyParser ¶
func NewFormURLEncodedBodyParser ¶
func NewFormURLEncodedBodyParser(v any) IBodyParser
func NewJsonBodyParser ¶
func NewJsonBodyParser(v any) IBodyParser
func NewMultipartFormDataBodyParser ¶ added in v1.2.0
func NewMultipartFormDataBodyParser(v any) IBodyParser
type IContextBuilder ¶
type IContextBuilder interface {
Build() Context
}
type IDTOFactory ¶
type IDTOFactory interface {
// contains filtered or unexported methods
}
IDTOFactory declares the interface for creating DTOs.
func NewDTOFactory ¶
func NewDTOFactory(contentType ...string) IDTOFactory
NewDTOFactory creates a concrete factory based on content type.
type IHeader ¶
type JsonBody ¶
type JsonBody struct {
// contains filtered or unexported fields
}
func (*JsonBody) ContentType ¶ added in v1.2.0
type MultipartFormDataBody ¶ added in v1.2.0
type MultipartFormDataBody struct {
// contains filtered or unexported fields
}
MultipartFormDataBody handles multipart/form-data encoding
func (*MultipartFormDataBody) ContentType ¶ added in v1.2.0
func (f *MultipartFormDataBody) ContentType() string
func (*MultipartFormDataBody) Parse ¶ added in v1.2.0
func (f *MultipartFormDataBody) Parse() *bytes.Buffer
type MultipartFormDataDTOFactory ¶ added in v1.2.0
type MultipartFormDataDTOFactory struct {
// contains filtered or unexported fields
}
type OptionConnector ¶
type OptionConnector func(info *Connector)
func WithHeaderConnector ¶
func WithHeaderConnector(header IHeader) OptionConnector
func WithHeaderContextBuilder ¶
func WithHeaderContextBuilder(ctxBuilder IContextBuilder) OptionConnector
type OptionRequest ¶
type OptionRequest func(request *Request)
func WithBody ¶
func WithBody(bodyParser IBodyParser) OptionRequest
func WithContextBuilder ¶
func WithContextBuilder(contextBuilder IContextBuilder) OptionRequest
func WithCookies ¶ added in v1.2.0
func WithCookies(cookies ...*http.Cookie) OptionRequest
func WithHeader ¶
func WithHeader(header IHeader) OptionRequest
func WithMethod ¶
func WithMethod(method HTTPMethod) OptionRequest
func WithQuery ¶
func WithQuery(query IQuery) OptionRequest
type Request ¶
type Request struct { URI URI Method HTTPMethod Header IHeader Query IQuery BodyParser IBodyParser Cookies []*http.Cookie // contains filtered or unexported fields }
func NewRequest ¶
func NewRequest(path string, opts ...OptionRequest) *Request
NewRequest creates a new request baseUrl: the base url ex: http://localhost:8080, http://localhost/path, path/, path?lorem=ipsum opts: options to configure the request
func (*Request) MergeHeader ¶ added in v1.2.0
func (*Request) SetBaseUrl ¶ added in v1.2.0
func (*Request) SetContextBuilder ¶ added in v1.2.0
func (r *Request) SetContextBuilder(contextBuilder IContextBuilder) *Request
type RequestDTO ¶ added in v1.1.0
type Response ¶
type Response struct { StatusCode int Header IHeader Data []byte Request RequestDTO }
func NewErrorResponse ¶ added in v1.1.0
func (Response) RequestBody ¶
func (Response) RequestBodyOrFail ¶ added in v1.1.0
func (Response) RequestDTO ¶ added in v1.1.0
func (Response) RequestDTOorFail ¶ added in v1.1.0
func (Response) ResponseBody ¶ added in v1.0.2
Source Files ¶
Click to show internal directories.
Click to hide internal directories.