Documentation ¶
Overview ¶
Copyright 2016 Wenhui Shen <www.webx.top>
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Index ¶
- func BuildKeys(limiter *config.Limiter, r engine.Request) [][]string
- func LimitByKeys(limiter *config.Limiter, keys []string) *errors.HTTPError
- func LimitByRequest(limiter *config.Limiter, r engine.Request) *errors.HTTPError
- func LimitHandler(limiter *config.Limiter) echo.MiddlewareFunc
- func LimitMiddleware(limiter *config.Limiter) echo.MiddlewareFunc
- func New(max int64, ttl time.Duration) *config.Limiter
- func RemoteIP(ipLookups []string, r engine.Request) string
- func SetResponseHeaders(limiter *config.Limiter, w engine.Response)
- func StringInSlice(sliceString []string, needle string) bool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildKeys ¶
BuildKeys generates a slice of keys to rate-limit by given config and request structs.
func LimitByKeys ¶
LimitByKeys keeps track number of request made by keys separated by pipe. It returns HTTPError when limit is exceeded.
func LimitByRequest ¶
LimitByRequest builds keys based on http.Request struct, loops through all the keys, and check if any one of them returns HTTPError.
func LimitHandler ¶
func LimitHandler(limiter *config.Limiter) echo.MiddlewareFunc
func LimitMiddleware ¶
func LimitMiddleware(limiter *config.Limiter) echo.MiddlewareFunc
func SetResponseHeaders ¶
SetResponseHeaders configures X-Rate-Limit-Limit and X-Rate-Limit-Duration
func StringInSlice ¶
StringInSlice finds needle in a slice of strings.
Types ¶
This section is empty.