Documentation ¶
Index ¶
- func CheckPasswordHash(password, hash []byte) (err error)
- func CheckPasswordHashString(password, hash string) (err error)
- func DateStrTotime(dateStr string) (result time.Time, err error)
- func ENVJSONArray(name string) (value []interface{}, err error)
- func ENVJSONObj(name string) (value map[string]interface{}, err error)
- func FileNameWithoutExtension(fileName string) string
- func GetStackTrace() (trace []string)
- func HashPassword(password []byte) ([]byte, error)
- func HashPasswordString(password string) (string, error)
- func InitSnowflake(machineIDs ...int) (snowflakeGen *snowflake.Generator)
- func RandomHash() (string, error)
- func RandomKey() (string, error)
- func RemoveIndex(s []string, index int) []string
- func StructCheckSumSha256(obj interface{}, checksum string) error
- func StructSumSha256(obj interface{}) string
- func TimeToDGADate(dateTime time.Time) (dgaDate string)
- func UUIDv4() (uuidStr string, err error)
- func ValidCID(cid string) (result bool, err error)
- func WhereAmI(skipList ...int) string
- type AuthType
- type Ctx
- func (c *Ctx) BasicAuth(user, passwd string) error
- func (c *Ctx) FormValueArray(name string, sep ...string) (result []string)
- func (c *Ctx) FormValueBase64(name string) string
- func (c *Ctx) FormValueBool(name string) bool
- func (c *Ctx) FormValueDate(name string) time.Time
- func (c *Ctx) FormValueDateTime(name string) time.Time
- func (c *Ctx) FormValueFloat64(name string) (float64, error)
- func (c *Ctx) FormValueFloat64Default(name string, def float64) float64
- func (c *Ctx) FormValueInt(name string) (int, error)
- func (c *Ctx) FormValueInt64(name string) (int64, error)
- func (c *Ctx) FormValueInt64Default(name string, def int64) int64
- func (c *Ctx) FormValueIntDefault(name string, def int) int
- func (c *Ctx) FormValueTime(name string) time.Time
- func (c *Ctx) FormValueTrim(name string) string
- func (c *Ctx) ParamBase64(name string) string
- func (c *Ctx) ParamBool(name string) bool
- func (c *Ctx) ParamDate(name string) time.Time
- func (c *Ctx) ParamDateTime(name string) time.Time
- func (c *Ctx) ParamFloat64(name string) (float64, error)
- func (c *Ctx) ParamFloat64Default(name string, def float64) float64
- func (c *Ctx) ParamInt(name string) (int, error)
- func (c *Ctx) ParamInt64(name string) (int64, error)
- func (c *Ctx) ParamInt64Default(name string, def int64) int64
- func (c *Ctx) ParamIntDefault(name string, def int) int
- func (c *Ctx) ParamTime(name string) time.Time
- func (c *Ctx) ParamTrim(name string) string
- type Error
- type GrantType
- type HttpAuth
- type Mail
- type OauthErr
- type OauthRequest
- type OauthResponse
- type ResponseError
- type ResponseForm
- type ResponseType
- type ResultInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckPasswordHash ¶
CheckPasswordHash with bcrypt
func CheckPasswordHashString ¶
CheckPasswordHash with bcrypt
func ENVJSONArray ¶
func ENVJSONObj ¶
func GetStackTrace ¶
func GetStackTrace() (trace []string)
GetStackTrace prints the stack trace with given error by the formatter. If the error is not traceable, empty string is returned.
func HashPasswordString ¶
HashPassword with bcrypt
func InitSnowflake ¶
InitSnowflake machine id base on process id
func StructCheckSumSha256 ¶
func StructSumSha256 ¶
func StructSumSha256(obj interface{}) string
func TimeToDGADate ¶
Types ¶
type Ctx ¶
type Ctx struct {
*fiber.Ctx
}
Ctx represents the context of the current HTTP request. It holds request and response objects, path, path parameters, data and registered handler.
func (*Ctx) FormValueArray ¶
FormValueInt returns the form field value for the provided name, as string array.
If not found returns empty array.
func (*Ctx) FormValueBase64 ¶
FormValueBase64 returns the form field value for the provided name.
If value encoded with base64 return will be decoded string.
func (*Ctx) FormValueBool ¶
FormValueBool returns the form field value for the provided name, as bool.
If not found or value is false, then it returns true, otherwise false.
func (*Ctx) FormValueDate ¶
FormValueDate returns the form field date value for the provided name. https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/date
func (*Ctx) FormValueDateTime ¶
FormValueDateTime returns the form field datetime-local value for the provided name. https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/datetime-local
func (*Ctx) FormValueFloat64 ¶
FormValueFloat64 returns the form field value for the provided name, as float64.
If not found returns 0 and a non-nil error.
func (*Ctx) FormValueFloat64Default ¶
FormValueFloat64Default returns the form field value for the provided name, as float64.
If not found or parse errors returns the "def".
func (*Ctx) FormValueInt ¶
FormValueInt returns the form field value for the provided name, as int.
If not found returns 0 and a non-nil error.
func (*Ctx) FormValueInt64 ¶
FormValueInt64 returns the form field value for the provided name, as float64.
If not found returns 0 and a no-nil error.
func (*Ctx) FormValueInt64Default ¶
FormValueInt64Default returns the form field value for the provided name, as int64.
If not found or parse errors returns the "def".
func (*Ctx) FormValueIntDefault ¶
FormValueIntDefault returns the form field value for the provided name, as int.
If not found returns or parse errors the "def".
func (*Ctx) FormValueTime ¶
FormValueTime returns the form field time value for the provided name. https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/time
func (*Ctx) FormValueTrim ¶
FormValueTrim returns the form field value for the provided name, without trailing spaces.
func (*Ctx) ParamBase64 ¶
ParamBase64 returns path parameter by name.
If value encoded with base64 return will be decoded string.
func (*Ctx) ParamBool ¶
ParamBool returns path parameter by name, as bool.
If not found or value is false, then it returns true, otherwise false.
func (*Ctx) ParamDate ¶
ParamDate returns the form field date value for the provided name. https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/date
func (*Ctx) ParamDateTime ¶
ParamDateTime returns the form field datetime-local value for the provided name. https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/datetime-local
func (*Ctx) ParamFloat64 ¶
ParamFloat64 returns path parameter by name, as float64.
If not found returns 0 and a non-nil error.
func (*Ctx) ParamFloat64Default ¶
ParamFloat64Default returns path parameter by name, as float64.
If not found or parse errors returns the "def".
func (*Ctx) ParamInt ¶
ParamInt returns path parameter by name, as int.
If not found returns 0 and a non-nil error.
func (*Ctx) ParamInt64 ¶
ParamInt64 returns path parameter by name, as float64.
If not found returns 0 and a no-nil error.
func (*Ctx) ParamInt64Default ¶
ParamInt64Default returns path parameter by name, as int64.
If not found or parse errors returns the "def".
func (*Ctx) ParamIntDefault ¶
ParamIntDefault returns path parameter by name, as int.
If not found returns or parse errors the "def".
func (*Ctx) ParamTime ¶
ParamTime returns the form field time value for the provided name. https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/time
type Error ¶ added in v0.1.1
type Error struct { Code int `json:"code"` Source interface{} `json:"source,omitempty"` Title string `json:"title,omitempty"` Message string `json:"message,omitempty"` }
Error represents an error that occurred while handling a request.
func NewErrorSource ¶ added in v0.1.7
type HttpAuth ¶
type HttpAuth struct { Type AuthType `json:"auth_type"` Token string `json:"token,omitempty"` Username string `json:"username,omitempty"` Password string `json:"password,omitempty"` }
func ExtractAuthString ¶
type Mail ¶
type OauthRequest ¶
type OauthRequest struct { APIKey string `json:"client_id" form:"client_id" query:"client_id"` APISecret string `json:"client_secret" form:"client_secret" query:"client_secret"` ResponseType string `json:"response_type" form:"response_type" query:"response_type"` RedirectURI string `json:"redirect_uri" form:"redirect_uri" query:"redirect_uri"` Scope string `json:"scope" form:"scope" query:"scope"` State string `json:"state" form:"state" query:"state"` Code string `json:"code" form:"code" query:"code"` GrantType string `json:"grant_type" form:"grant_type" query:"grant_type"` UserName string `json:"username" form:"username" query:"username"` Password string `json:"password" form:"password" query:"password"` RefreshToken string `json:"refresh_token" form:"refresh_token" query:"refresh_token"` Token string `json:"token" form:"token" query:"token"` }
OauthRequest oauth request by IETF
type OauthResponse ¶
type OauthResponse struct { Scope string `json:"scope,omitempty"` State string `json:"state,omitempty"` Code string `json:"code,omitempty"` Error OauthErr `json:"error,omitempty"` ErrorDesc string `json:"error_description,omitempty"` ErrorURI string `json:"error_uri,omitempty"` AccessToken string `json:"access_token,omitempty"` IDToken string `json:"id_token,omitempty"` TokenType string `json:"token_type,omitempty"` ExpiresIn int `json:"expires_in,omitempty"` RefreshToken string `json:"refresh_token,omitempty"` Data interface{} `json:"data,omitempty"` }
OauthResponse oauth request by IETF
type ResponseError ¶ added in v0.1.1
type ResponseError Error
ResponseError backward complatible Error
type ResponseForm ¶
type ResponseForm struct { Success bool `json:"success"` Result interface{} `json:"result,omitempty"` Data interface{} `json:"data,omitempty"` Messages []string `json:"messages,omitempty"` Errors []ResponseError `json:"errors,omitempty"` ResultInfo *ResultInfo `json:"result_info,omitempty"` }
type ResponseType ¶
type ResponseType string
ResponseType Oauth response type
const ( ResponseTypeCode ResponseType = "code" ResponseTypeToken ResponseType = "token" )
Responsetype constant