Documentation ¶
Index ¶
- Constants
- Variables
- func CreateClient(ctx *cli.Context) (*Client, AuthData, error)
- func DefaultTransport() *http.Transport
- func GetUser[T auth.User](gtx context.Context) T
- func GetUserId(etx echo.Context) string
- func MustGetUser(etx echo.Context) auth.User
- func SendJSON(etx echo.Context, data interface{}) error
- func StrMsg(err *echo.HTTPError) string
- func WithClientFlags(withAuth bool, envPrefix string, flags ...cli.Flag) []cli.Flag
- type ApiResult
- type AuthData
- type Client
- func (client *Client) Delete(gtx context.Context, urlArgs ...string) *ApiResult
- func (client *Client) Get(gtx context.Context, urlArgs ...string) *ApiResult
- func (client *Client) Post(gtx context.Context, content interface{}, urlArgs ...string) *ApiResult
- func (client *Client) Put(gtx context.Context, content interface{}, urlArgs ...string) *ApiResult
- func (client *Client) RemoteHost() (string, error)
- func (client *Client) SetToken(token string) *Client
- func (client *Client) SetUser(user auth.User) *Client
- func (client *Client) User() auth.User
- type Endpoint
- type ParamGetter
- func (pm *ParamGetter) BadReqError() error
- func (pm *ParamGetter) Bool(name string) bool
- func (pm *ParamGetter) Error() error
- func (pm *ParamGetter) Float64(name string) float64
- func (pm *ParamGetter) HasError() bool
- func (pm *ParamGetter) Int(name string) int
- func (pm *ParamGetter) Int64(name string) int64
- func (pm *ParamGetter) QueryBool(name string) bool
- func (pm *ParamGetter) QueryBoolOr(name string, def bool) bool
- func (pm *ParamGetter) QueryFloat64(name string) float64
- func (pm *ParamGetter) QueryFloat64Or(name string, def float64) float64
- func (pm *ParamGetter) QueryInt(name string) int
- func (pm *ParamGetter) QueryInt64(name string) int64
- func (pm *ParamGetter) QueryInt64Or(name string, def int64) int64
- func (pm *ParamGetter) QueryIntOr(name string, def int) int
- func (pm *ParamGetter) QueryJSON(name string, out interface{}) *ParamGetter
- func (pm *ParamGetter) QueryStr(name string) string
- func (pm *ParamGetter) QueryStrOr(name, def string) string
- func (pm *ParamGetter) QueryUInt(name string) uint
- func (pm *ParamGetter) QueryUInt64Or(name string, def uint64) uint64
- func (pm *ParamGetter) QueryUInt64Param(name string) uint64
- func (pm *ParamGetter) QueryUIntOr(name string, def uint) uint
- func (pm *ParamGetter) Str(name string) string
- func (pm *ParamGetter) UInt(name string) uint
- func (pm *ParamGetter) UInt64(name string) uint64
- func (pm *ParamGetter) WriteDetailedError(w io.Writer)
- type Server
Constants ¶
View Source
const (
EnvPrintAllAccess = "VLIBX_HTTP_PRINT_ALL_ACCESS"
)
View Source
const UserKey = userKeyType("requestUser")
Variables ¶
View Source
var ( ErrNotFound = errors.New("client.http.notFound") ErrForbidden = errors.New("client.http.forbidden") ErrInternalServerError = errors.New("client.http.internalServerError") ErrBadRequest = errors.New("client.http.badRequest") ErrOtherStatus = errors.New("client.http.otherStatus") ErrInvalidResponse = errors.New("client.http.invalidResponse") ErrClientError = errors.New("client.http.clientError") )
View Source
var (
ErrHttpParam = errors.New("error.http.param")
)
Functions ¶
func CreateClient ¶
func DefaultTransport ¶
func MustGetUser ¶
func WithClientFlags ¶
Types ¶
type Client ¶
func (*Client) RemoteHost ¶
type Endpoint ¶
type Endpoint struct { Method string Path string Category string Desc string Version string Role auth.Role Permissions []string Route *echo.Route Handler echo.HandlerFunc }
func MustGetEndpoint ¶
func MustGetEndpoint(etx echo.Context) *Endpoint
type ParamGetter ¶
type ParamGetter struct {
// contains filtered or unexported fields
}
func NewParamGetter ¶
func NewParamGetter(etx echo.Context) *ParamGetter
func (*ParamGetter) BadReqError ¶
func (pm *ParamGetter) BadReqError() error
func (*ParamGetter) Bool ¶
func (pm *ParamGetter) Bool(name string) bool
func (*ParamGetter) Error ¶
func (pm *ParamGetter) Error() error
func (*ParamGetter) Float64 ¶
func (pm *ParamGetter) Float64(name string) float64
func (*ParamGetter) HasError ¶
func (pm *ParamGetter) HasError() bool
func (*ParamGetter) Int ¶
func (pm *ParamGetter) Int(name string) int
func (*ParamGetter) Int64 ¶
func (pm *ParamGetter) Int64(name string) int64
func (*ParamGetter) QueryBool ¶
func (pm *ParamGetter) QueryBool(name string) bool
func (*ParamGetter) QueryBoolOr ¶
func (pm *ParamGetter) QueryBoolOr(name string, def bool) bool
func (*ParamGetter) QueryFloat64 ¶
func (pm *ParamGetter) QueryFloat64(name string) float64
func (*ParamGetter) QueryFloat64Or ¶
func (pm *ParamGetter) QueryFloat64Or(name string, def float64) float64
func (*ParamGetter) QueryInt ¶
func (pm *ParamGetter) QueryInt(name string) int
func (*ParamGetter) QueryInt64 ¶
func (pm *ParamGetter) QueryInt64(name string) int64
func (*ParamGetter) QueryInt64Or ¶
func (pm *ParamGetter) QueryInt64Or(name string, def int64) int64
func (*ParamGetter) QueryIntOr ¶
func (pm *ParamGetter) QueryIntOr(name string, def int) int
func (*ParamGetter) QueryJSON ¶
func (pm *ParamGetter) QueryJSON(name string, out interface{}) *ParamGetter
func (*ParamGetter) QueryStr ¶
func (pm *ParamGetter) QueryStr(name string) string
func (*ParamGetter) QueryStrOr ¶
func (pm *ParamGetter) QueryStrOr(name, def string) string
func (*ParamGetter) QueryUInt ¶
func (pm *ParamGetter) QueryUInt(name string) uint
func (*ParamGetter) QueryUInt64Or ¶
func (pm *ParamGetter) QueryUInt64Or(name string, def uint64) uint64
func (*ParamGetter) QueryUInt64Param ¶
func (pm *ParamGetter) QueryUInt64Param(name string) uint64
func (*ParamGetter) QueryUIntOr ¶
func (pm *ParamGetter) QueryUIntOr(name string, def uint) uint
func (*ParamGetter) Str ¶
func (pm *ParamGetter) Str(name string) string
func (*ParamGetter) UInt ¶
func (pm *ParamGetter) UInt(name string) uint
func (*ParamGetter) UInt64 ¶
func (pm *ParamGetter) UInt64(name string) uint64
func (*ParamGetter) WriteDetailedError ¶
func (pm *ParamGetter) WriteDetailedError(w io.Writer)
Click to show internal directories.
Click to hide internal directories.