Documentation ¶
Index ¶
- func AddCacheHeader(header *http.Header, maxAge int)
- func AddXForwardHeader(header *http.Header, host string)
- func ContainsString(s []string, str string) bool
- func ConvGraphQLID(id interface{}) *uint
- func CountLines(r io.Reader) (uint, error)
- func GetIntOrDefault(values url.Values, key string, defaultValue int) int
- func Hash(values ...string) string
- func If[T any](cond bool, vtrue, vfalse T) T
- func InvalidParameterError(name string) error
- func NewBackgroundContextWithValues(src context.Context) context.Context
- func NewUTF8Reader(reader io.Reader, sourceCharset string) (io.Reader, error)
- func OneIsEmpty(values ...*string) bool
- func OpenResource(location string) (io.ReadCloser, error)
- func ParseGraphQLArgument[T string | bool | int](args map[string]interface{}, name string) *T
- func ParseGraphQLID(args map[string]interface{}, name string) *uint
- func PtrValueOr[T any](obj *T, fallback T) T
- func RequireParameterError(name string) error
- func ToUTF8(iso string) string
- func Truncate(value string, size int) string
- func WriteProblemDetail(w http.ResponseWriter, title, detail string, status int)
- type FieldsValidator
- type HashIDHandler
- type HtpasswdFile
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddCacheHeader ¶ added in v1.2.0
AddCacheHeader add cache headers
func AddXForwardHeader ¶ added in v1.2.0
AddXForwardHeader add X-Forwarded-For header
func ContainsString ¶ added in v1.1.0
ContainsString retrn true if the slice contains the string
func ConvGraphQLID ¶
func ConvGraphQLID(id interface{}) *uint
ParseGraphQLID parse GraphQL argument as uint
func GetIntOrDefault ¶
GetIntOrDefault return value as int or the default
func InvalidParameterError ¶
InvalidParameterError create invalid parameter error
func NewBackgroundContextWithValues ¶
NewBackgroundContextWithValues create new context with same values than another context
func NewUTF8Reader ¶
NewUTF8Reader converts a reader from a charset to UTF-8
func OneIsEmpty ¶
OneIsEmpty test if one of the pointers is nil or reference an empty string
func OpenResource ¶
func OpenResource(location string) (io.ReadCloser, error)
OpenResource open local or remote resource as a Reader
func ParseGraphQLArgument ¶
ParseGraphQLArgument parse GraphQL argument
func ParseGraphQLID ¶
ParseGraphQLID parse GraphQL argument as uint
func PtrValueOr ¶
func PtrValueOr[T any](obj *T, fallback T) T
PtrValueOr return value of the pointer or a fallback if nil
func RequireParameterError ¶
RequireParameterError create require parameter error
func WriteProblemDetail ¶
func WriteProblemDetail(w http.ResponseWriter, title, detail string, status int)
WriteProblemDetail write error as JSON Problem Details format
Types ¶
type FieldsValidator ¶
type FieldsValidator struct {
// contains filtered or unexported fields
}
func (*FieldsValidator) Error ¶
func (v *FieldsValidator) Error() error
func (*FieldsValidator) Validate ¶
func (v *FieldsValidator) Validate(name string, isValid func() bool)
type HashIDHandler ¶
type HashIDHandler struct {
// contains filtered or unexported fields
}
HashIDHandler is used to hash a string with hashid algorythm
func NewHashIDHandler ¶
func NewHashIDHandler(salt []byte) (*HashIDHandler, error)
NewHashIDHandler creates hashid handler
func (*HashIDHandler) Decode ¶
func (hid *HashIDHandler) Decode(hash string) ([]int, error)
Decode value from hashid
func (*HashIDHandler) Encode ¶
func (hid *HashIDHandler) Encode(values []int) string
Encode values into hashid
type HtpasswdFile ¶
type HtpasswdFile struct {
// contains filtered or unexported fields
}
HtpasswdFile is a map for usernames to passwords.
func NewHtpasswdFromFile ¶
func NewHtpasswdFromFile(location string) (*HtpasswdFile, error)
newHtpasswdFromFile reads the users and passwords from a htpasswd file and returns them.
func (*HtpasswdFile) Authenticate ¶
func (h *HtpasswdFile) Authenticate(username, password string) bool