Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrSyntax = errors.New("syntax error")
Functions ¶
func RegisterFactory ¶
func RegisterFactory(n ProcessorFactory)
RegisterFactory registers a processor factory for a directive.
Types ¶
type Location ¶
type Location struct { Seq int // 定义的顺序 Priority ModifierPriority // 匹配级别,从0开始,数字越小,匹配优先级越高 Modifier Modifier Path string Processors Processors Pattern *regexp.Regexp }
Location is the location.
type Modifier ¶
type Modifier string
Modifier is the location modifier.
func (Modifier) Priority ¶
func (m Modifier) Priority() ModifierPriority
Priority returns the priority of the location matching.
type ModifierPriority ¶
type ModifierPriority int
ModifierPriority defines the priority of the modifier. https://end0tknr.wordpress.com/2015/12/22/location-match-priority-in-nginx/. https://artfulrobot.uk/blog/untangling-nginx-location-block-matching-algorithm. https://blog.csdn.net/qq_15766181/article/details/72829672. priority | prefix | example. 1 | = (exactly) | location = /path. 2 | ^~ (forward match) | location = /image. 3 | ~ or ~* (regular & case-(in)sensitive) | location ~ /image/. 4 | NONE (forward match) | location /image.
const ( // ModifierExactly like location = /path matches the query / only. ModifierExactly ModifierPriority = iota + 1 // ModifierForward like location ^~ /path. // matches any query beginning with /path/ and halts searching, // so regular expressions will not be checked. ModifierForward // ModifierRegular like location ~ \.(gif|jpg|jpeg)$ // or like location ~* .(jpg|png|bmp). ModifierRegular // ModifierNone means none modifier for the location. ModifierNone )
https://stackoverflow.com/questions/5238377/nginx-location-priority
type ProcessResult ¶
type ProcessResult int
const ( ProcessContinue ProcessResult = iota ProcessTerminate )
func Welcome ¶
func Welcome(w http.ResponseWriter) ProcessResult
type Processor ¶
type Processor interface { Naming GetProcessSeq() ProcessSeq Parse(path string, name string, params []string) error Do(l Location, w http.ResponseWriter, r *http.Request) ProcessResult }
Processor is the directive processor in a location.
type ProcessorFactory ¶
type Processors ¶
type Processors []Processor
Processors is the slice of processors for sorting Interface satisfied.
func (Processors) Len ¶
func (l Processors) Len() int
func (Processors) Less ¶
func (l Processors) Less(i, j int) bool
func (Processors) Swap ¶
func (l Processors) Swap(i, j int)
type Return ¶
Return means http://nginx.org/en/docs/http/ngx_http_rewrite_module.html#return. Syntax: return code [text];.
func (*Return) Do ¶
func (r *Return) Do(l Location, w http.ResponseWriter, rq *http.Request) ProcessResult
func (*Return) GetProcessSeq ¶
func (r *Return) GetProcessSeq() ProcessSeq