Documentation ¶
Overview ¶
Package queryparser parses a common "q" http GET variable to look for text filters, which can be used for advanced searching. For example:
Hello World tags:example,world foo:"something quoted" author:lrstanley
go-queryparser also strips out not very safe/useful characters by default. See the DefaultCut function for details (and New() for how you can do this yourself.)
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultCut ¶
DefaultCut is the default cut function, which allowed stripping out potentially unwanted characters from filter fields and raw text. Only allows " _,-.:A-Za-z0-9" (or unicode equivalents).
Types ¶
type Options ¶
type Options struct { // CutFn allows excluding specific characters from being allowed within // the filter fields. When the function returns true on a rune, it will // be excluded from the filter field. CutFn func(rune) bool // Allowed is a slice of allowed filter names. If no allowed filter names // are provided, all are considered allowed. Allowed []string }
Options allow the adjustment of allowed filters and characters.
type Parser ¶
type Parser struct {
// contains filtered or unexported fields
}
Parser represents a parser.
type Query ¶
type Query struct { // Raw is the raw (trailing) text of items that weren't filters. Raw string // contains filtered or unexported fields }
Query represents filtered input.
func (*Query) Get ¶
Get returns the results of the filter if it exists, and if it successfully found a result.
func (*Query) GetOne ¶
GetOne returns the last known result for the filter, if it exists. Useful if you only want a user to define a filter once. The resulting string is empty if no filter of that key was found.