Documentation ¶
Index ¶
- Constants
- Variables
- func CheckPassword(format string, hashedPassword string, args ...interface{}) error
- func ContextWithRequester(ctx context.Context, requester Requester) context.Context
- func ConvertWeight(weight float64, from, to constant.WeightUnit) float64
- func ErrorResponse(ctx *gin.Context, err error)
- func HashPassword(format string, args ...interface{}) (string, error)
- func NewDataResponse(data interface{}) *successResponse
- func NewRequester(uid string) *requesterData
- func NewResponse(data, paging, extra interface{}) *successResponse
- func RandomString(length int) (string, error)
- func SuccessResponse(ctx *gin.Context, data *successResponse)
- type Config
- type DefaultError
- type Requester
- type StatusCodeCarrier
Constants ¶
View Source
const KeyRequester = "requester"
Variables ¶
View Source
var ErrBadRequest = DefaultError{ StatusField: http.StatusText(http.StatusBadRequest), ErrorField: "The request was invalid or contained malformed parameters", CodeField: http.StatusBadRequest, }
View Source
var ErrConflict = DefaultError{ StatusField: http.StatusText(http.StatusConflict), ErrorField: "A conflict occurred with the current state of the resource", CodeField: http.StatusConflict, }
View Source
var ErrForbidden = DefaultError{ StatusField: http.StatusText(http.StatusForbidden), ErrorField: "Access to the requested page or resource is forbidden", CodeField: http.StatusForbidden, }
View Source
var ErrInternalServerError = DefaultError{ StatusField: http.StatusText(http.StatusInternalServerError), ErrorField: "An internal server error occurred. Please try again later", CodeField: http.StatusInternalServerError, }
View Source
var ErrNotFound = DefaultError{ StatusField: http.StatusText(http.StatusNotFound), ErrorField: "The requested page or resource could not be found", CodeField: http.StatusNotFound, }
View Source
var ErrTimeout = DefaultError{ StatusField: http.StatusText(http.StatusRequestTimeout), ErrorField: "The request timed out", CodeField: http.StatusRequestTimeout, }
View Source
http.StatusText(http.StatusUnauthorized), ErrorField: "Access denied. Please authenticate with valid credentials", CodeField: http.StatusUnauthorized, }StatusField:
View Source
var ErrUnsupportedMediaType = DefaultError{ StatusField: http.StatusText(http.StatusUnsupportedMediaType), ErrorField: "The media type of the requested resource is not supported", CodeField: http.StatusUnsupportedMediaType, }
Functions ¶
func CheckPassword ¶
func ContextWithRequester ¶
func ConvertWeight ¶
func ConvertWeight(weight float64, from, to constant.WeightUnit) float64
func ErrorResponse ¶
func HashPassword ¶
func NewDataResponse ¶
func NewDataResponse(data interface{}) *successResponse
func NewRequester ¶
func NewRequester(uid string) *requesterData
func NewResponse ¶
func NewResponse(data, paging, extra interface{}) *successResponse
func RandomString ¶
func SuccessResponse ¶
Types ¶
type Config ¶
type Config struct { ENV string `mapstructure:"ENV"` SecretKey string `mapstructure:"SECRET_KEY"` DBSource string `mapstructure:"DB_SOURCE"` MigrationURL string `mapstructure:"MIGRATION_URL"` ServerAddress string `mapstructure:"SERVER_ADDRESS"` AccessTokenExpiresIn time.Duration `mapstructure:"ACCESS_TOKEN_EXPIRES_IN"` RefreshTokenExpiresIn time.Duration `mapstructure:"REFRESH_TOKEN_EXPIRES_IN"` }
func LoadConfig ¶
type DefaultError ¶
type DefaultError struct { StatusField string `json:"status,omitempty"` CodeField int `json:"code,omitempty"` ErrorField string `json:"message"` DebugField string `json:"debug,omitempty"` }
func (DefaultError) Error ¶
func (e DefaultError) Error() string
func (DefaultError) Is ¶
func (e DefaultError) Is(err error) bool
func (DefaultError) StatusCode ¶
func (e DefaultError) StatusCode() int
func (DefaultError) WithDebug ¶
func (e DefaultError) WithDebug(debug string) *DefaultError
func (DefaultError) WithError ¶
func (e DefaultError) WithError(message string) *DefaultError
type StatusCodeCarrier ¶
type StatusCodeCarrier interface {
StatusCode() int
}
Click to show internal directories.
Click to hide internal directories.