Documentation
¶
Index ¶
- Constants
- func IsCodeError() bool
- type FctHttpClient
- type FctTLSDefault
- type Options
- func (o Options) GetClientHTTP(servername string) *http.Client
- func (o Options) New(ctx libcfg.FuncContext, cli FctHttpClient, tls FctTLSDefault) (Request, error)
- func (o Options) SetDefaultTLS(fct FctTLSDefault)
- func (o Options) Update(req Request, ctx libcfg.FuncContext, cli FctHttpClient, tls FctTLSDefault) (Request, error)
- func (o Options) Validate() liberr.Error
- type OptionsAuth
- type OptionsCredentials
- type OptionsHealth
- type OptionsHealthResult
- type OptionsToken
- type Request
- type RequestError
Constants ¶
View Source
const ( ErrorParamsEmpty liberr.CodeError = iota + liberr.MinPkgRequest ErrorParamsInvalid ErrorValidatorError ErrorCreateRequest ErrorSendRequest ErrorResponseInvalid ErrorResponseLoadBody ErrorResponseStatus ErrorResponseUnmarshall ErrorResponseContainsNotFound ErrorResponseNotContainsFound )
Variables ¶
This section is empty.
Functions ¶
func IsCodeError ¶
func IsCodeError() bool
Types ¶
type FctTLSDefault ¶
type Options ¶
type Options struct {
Endpoint string `json:"endpoint" yaml:"endpoint" toml:"endpoint" mapstructure:"endpoint" validate:"required,url"`
HttpClient libhtc.Options `json:"http_client" yaml:"http_client" toml:"http_client" mapstructure:"http_client" validate:"required,dive"`
Auth OptionsAuth `json:"auth" yaml:"auth" toml:"auth" mapstructure:"auth" validate:"required,dive"`
Health OptionsHealth `json:"health" yaml:"health" toml:"health" mapstructure:"health" validate:"required,dive"`
// contains filtered or unexported fields
}
func (Options) New ¶
func (o Options) New(ctx libcfg.FuncContext, cli FctHttpClient, tls FctTLSDefault) (Request, error)
func (Options) SetDefaultTLS ¶
func (o Options) SetDefaultTLS(fct FctTLSDefault)
func (Options) Update ¶
func (o Options) Update(req Request, ctx libcfg.FuncContext, cli FctHttpClient, tls FctTLSDefault) (Request, error)
type OptionsAuth ¶
type OptionsAuth struct {
Basic OptionsCredentials `json:"basic" yaml:"basic" toml:"basic" mapstructure:"basic" validate:"required,dive"`
Bearer OptionsToken `json:"bearer" yaml:"bearer" toml:"bearer" mapstructure:"bearer" validate:"required,dive"`
}
type OptionsCredentials ¶
type OptionsHealth ¶
type OptionsHealth struct {
Enable bool `json:"enable" yaml:"enable" toml:"enable" mapstructure:"enable"`
Endpoint string `json:"endpoint" yaml:"endpoint" toml:"endpoint" mapstructure:"endpoint" validate:"required,url"`
Auth OptionsAuth `json:"auth" yaml:"auth" toml:"auth" mapstructure:"auth" validate:"required,dive"`
Result OptionsHealthResult `json:"result" yaml:"result" toml:"result" mapstructure:"result" validate:"required,dive"`
Status libsts.ConfigStatus `json:"status" yaml:"status" toml:"status" mapstructure:"status" validate:"required,dive"`
}
type OptionsHealthResult ¶
type OptionsHealthResult struct {
ValidHTTPCode []int `json:"valid_http_code" yaml:"valid_http_code" toml:"valid_http_code" mapstructure:"valid_http_code"`
InvalidHTTPCode []int `json:"invalid_http_code" yaml:"invalid_http_code" toml:"invalid_http_code" mapstructure:"invalid_http_code"`
Contain []string `json:"contain" yaml:"contain" toml:"contain" mapstructure:"contain"`
NotContain []string `json:"not_contain" yaml:"not_contain" toml:"not_contain" mapstructure:"not_contain"`
}
type OptionsToken ¶
type Request ¶
type Request interface {
Clone() (Request, error)
New() (Request, error)
GetOption() *Options
SetOption(opt *Options) error
SetClient(fct FctHttpClient)
SetContext(fct libcfg.FuncContext)
SetEndpoint(u string) error
GetEndpoint() string
SetPath(raw bool, path string)
AddPath(raw bool, path ...string)
SetMethod(mtd string)
GetMethod() string
CleanParams()
DelParams(key string)
SetParams(key, val string)
AddParams(key, val string)
GetFullUrl() *url.URL
SetFullUrl(u *url.URL)
AuthBearer(token string)
AuthBasic(user, pass string)
ContentType(content string)
CleanHeader()
DelHeader(key string)
SetHeader(key, value string)
AddHeader(key, value string)
BodyJson(body interface{}) error
BodyReader(body io.Reader, contentType string)
Error() RequestError
IsError() bool
Do() (*http.Response, liberr.Error)
DoParse(model interface{}, validStatus ...int) liberr.Error
StatusRegister(sts libsts.RouteStatus, prefix string)
StatusRegisterInfo(fct libsts.FctInfo)
}
func New ¶
func New(ctx libcfg.FuncContext, cli FctHttpClient, opt Options) (Request, error)
Click to show internal directories.
Click to hide internal directories.