Documentation
¶
Index ¶
- Variables
- func FileServer(dir http.Dir) http.Handler
- func GetAbsURL(req *http.Request) url.URL
- func HtmlifyContext(value interface{}, ctx *core.Context) template.HTML
- func HumanizeString(str string) string
- func HumanizeStringU(str string) string
- func IndirectItemType(v interface{}) (typ reflect.Type)
- func IndirectType(v interface{}) (typ reflect.Type)
- func ModelType(value interface{}) reflect.Type
- func NamifyString(s string) string
- func NewValue(t reflect.Type) (v reflect.Value)
- func NoEmptyStrings(values ...string) (res []string)
- func ParseFormKey(key string) (result []interface{}, err error)
- func ParseTagOption(str string) map[string]string
- func RenderHtmlTemplate(tpl string, data interface{}) template.HTML
- func SetCookie(cookie http.Cookie, context *core.Context)
- func SetNonZero(rvalue reflect.Value, value interface{})
- func SetZero(rvalue reflect.Value)
- func SortFormKeys(strs []string)
- func Stringify(object interface{}) string
- func StringifyContext(object interface{}, ctx *core.Context) string
- func StringsFilter(accept func(s string) bool, dst *[]string, src []string)
- func StringsJoin(sep, lastSep string, values ...string) string
- func StructType(v interface{}) (typ reflect.Type)
- func ToArray(value interface{}) (values []string)
- func ToFloat(value interface{}) float64
- func ToInt(value interface{}) int64
- func ToParamString(str string) (r string)
- func ToString(value interface{}) string
- func ToUint(value interface{}) uint64
- func ToUri(value string) string
- func Tuples(args ...string) (r [][]string)
- func TuplesIndex(args ...string) (r [][]string)
- func TypeId(tp interface{}) string
- type ContextKey
- type FormTree
- type FormTreeItem
- type FormTreeItemSlice
- type FormTreeMap
- type FormTreeSlice
- type PathValue
- type PathValues
- type ReadonlyMapString
- type TemplateFuncsData
- type URLGenerator
Constants ¶
This section is empty.
Variables ¶
var AppRoot, _ = os.Getwd()
AppRoot app root path
var DefaultLocale string
DefaultLang Default App Language
var FormatTime = func(date time.Time, layout string, context *core.Context) string {
return date.Format(layout)
}
FormatTime format time to string Overwrite the default logic with
utils.FormatTime = func(time time.Time, layout string, context *qor.Context) string { // .... }
var GetLocale = func(context *core.Context) string { if locale := context.Request.Header.Get("Locale"); locale != "" { return locale } if locale := context.Request.URL.Query().Get("locale"); locale != "" { if context.Writer != nil { context.Request.Header.Set("Locale", locale) SetCookie(http.Cookie{Name: "locale", Value: locale, Expires: time.Now().AddDate(1, 0, 0)}, context) } return locale } if locale, err := context.Request.Cookie("locale"); err == nil { return locale.Value } return DefaultLocale }
GetLocale get locale from request, cookie, after get the locale, will write the locale to the cookie if possible Overwrite the default logic with
utils.GetLocale = func(context *qor.Context) string { // .... }
var HTMLSanitizer = bluemonday.UGCPolicy()
HTMLSanitizer html sanitizer to avoid XSS
var ParseTime = func(timeStr string, context *core.Context) (time.Time, error) { return now.Parse(timeStr) }
ParseTime parse time from string Overwrite the default logic with
utils.ParseTime = func(timeStr string, context *qor.Context) (time.Time, error) { // .... }
Functions ¶
func FileServer ¶
FileServer file server that disabled file listing
func GetAbsURL ¶
GetAbsURL get absolute URL from request, refer: https://stackoverflow.com/questions/6899069/why-are-request-url-host-and-scheme-blank-in-the-development-server
func HumanizeString ¶
HumanizeString Humanize separates string based on capitalizd letters e.g. "OrderItem" -> "Order Item"
func HumanizeStringU ¶
HumanizeString Humanize separates string based on capitalizd letters e.g. "OrderItem" -> "Order Item" e.g. "Order_item" -> "Order Item"
func IndirectItemType ¶
func IndirectType ¶
func NamifyString ¶
HumanizeString Humanize separates string based on capitalizd letters e.g. "order_item-data" -> "OrderItemData"
func NoEmptyStrings ¶
func ParseFormKey ¶
func ParseTagOption ¶
ParseTagOption parse tag options to hash
func RenderHtmlTemplate ¶
func SetNonZero ¶
func Stringify ¶
func Stringify(object interface{}) string
Stringify stringify any data, if it is a struct, will try to use its Name, Title, Code field, else will use its primary key
func StringifyContext ¶
StringifyContext stringify any data, if it is a struct, will try to use its Name, Title, Code field, else will use its primary key
func StringsJoin ¶
func StructType ¶
func ToArray ¶
func ToArray(value interface{}) (values []string)
ToArray get array from value, will ignore blank string to convert it to array
func ToFloat ¶
func ToFloat(value interface{}) float64
ToFloat get float from value, if passed value is empty string, result will be 0
func ToInt ¶
func ToInt(value interface{}) int64
ToInt get int from value, if passed value is empty string, result will be 0
func ToParamString ¶
ToParamString replaces spaces and separates words (by uppercase letters) with underscores in a string, also downcase it e.g. ToParamString -> to_param_string, To ParamString -> to_param_string
func ToString ¶
func ToString(value interface{}) string
ToString get string from value, if passed value is a slice, will use the last element
func ToUint ¶
func ToUint(value interface{}) uint64
ToUint get uint from value, if passed value is empty string, result will be 0
func TuplesIndex ¶
Types ¶
type FormTree ¶
type FormTree struct { Map FormTreeMap `json:",omitempty"` Keys []string `json:",omitempty"` SliceMap map[int]*FormTreeItem `json:"-"` Slice FormTreeSlice `json:",omitempty"` }
func NewMultipartFormTree ¶
func (*FormTree) AddFile ¶
func (this *FormTree) AddFile(key []interface{}, files []*multipart.FileHeader)
type FormTreeItem ¶
type FormTreeItem struct { Tree *FormTree `json:",omitempty"` Values []string `json:",omitempty"` Files []*multipart.FileHeader `json:",omitempty"` Index int `json:",omitempty"` }
type FormTreeItemSlice ¶
type FormTreeItemSlice struct {
Items []*FormTreeItem
}
type FormTreeMap ¶
type FormTreeMap map[string]*FormTreeItem
type FormTreeSlice ¶
type FormTreeSlice []*FormTreeItem
type PathValues ¶
func ParamsMatch ¶
func ParamsMatch(source string, pth string) (*PathValues, string, bool)
ParamsMatch match string by param
func (*PathValues) Add ¶
func (p *PathValues) Add(key, value string)
func (*PathValues) Dict ¶
func (p *PathValues) Dict() map[string][]string
func (*PathValues) Get ¶
func (p *PathValues) Get(key string) *PathValue
type ReadonlyMapString ¶
type TemplateFuncsData ¶
type TemplateFuncsData struct {
// contains filtered or unexported fields
}
func NewTemplateFuncsData ¶
func NewTemplateFuncsData(funcs map[string]interface{}, data interface{}) *TemplateFuncsData
func (*TemplateFuncsData) Data ¶
func (tf *TemplateFuncsData) Data() interface{}
func (*TemplateFuncsData) Funcs ¶
func (tf *TemplateFuncsData) Funcs() map[string]interface{}