tollbooth_beego

package module
v0.0.0-...-a50e725 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 14, 2019 License: Apache-2.0 Imports: 4 Imported by: 0

README

tollbooth_beego

Beego middleware for rate limiting HTTP requests.

Five Minutes Tutorial

package main

import (
	"github.com/didip/tollbooth"
	"github.com/astaxie/beego"
	"github.com/didip/tollbooth/limiter"
	"github.com/tollbooth_beego"
)

var res *limiter.Limiter

func main() {

	res = tollbooth.NewLimiter(10, nil)

	res.SetMessage("已超过最大连接数,请稍后测试")

	beego.Router("/v1/aa",&Admin{},"get:Demo")

	beego.InsertFilter("/v1/*",beego.BeforeExec,tollbooth_beego.LimitHandler(res))

	beego.Run(":12345")


}



type Admin struct {

	beego.Controller
}

func (this *Admin) Demo()  {

	this.Ctx.Output.Body([]byte("testing"))
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LimitHandler

func LimitHandler(lmt *limiter.Limiter) beego.FilterFunc

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL