This repository has been archived by the owner on Dec 9, 2022. It is now read-only.
Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
reverse/multi.go
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
47 lines (37 sloc)
1.03 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copyright 2012 The Gorilla Authors. All rights reserved. | |
// Use of this source code is governed by a BSD-style | |
// license that can be found in the LICENSE file. | |
package reverse | |
import ( | |
"net/http" | |
) | |
// All ------------------------------------------------------------------------ | |
// NewAll returns a group of matchers that succeeds only if all of them match. | |
func NewAll(matchers []Matcher) All { | |
return All(matchers) | |
} | |
// All is a set of matchers, and all of them must match. | |
type All []Matcher | |
func (m All) Match(r *http.Request) bool { | |
for _, v := range m { | |
if !v.Match(r) { | |
return false | |
} | |
} | |
return true | |
} | |
// One ------------------------------------------------------------------------ | |
// NewOne returns a group of matchers that succeeds if one of them matches. | |
func NewOne(matchers []Matcher) One { | |
return One(matchers) | |
} | |
// One is a set of matchers, and at least one of them must match. | |
type One []Matcher | |
func (m One) Match(r *http.Request) bool { | |
for _, v := range m { | |
if v.Match(r) { | |
return true | |
} | |
} | |
return false | |
} |