Browse Source

docs: add example for mysql

master
evanchen333 6 months ago
parent
commit
9c02ed345b
  1. 25
      README.md

25
README.md

@ -27,6 +27,31 @@ func main() {
http.ListenAndServe(":8080", nil)
}
```
### Use Other Database
This library should comply with most databases, but is only tested with mysql.
```go
var l *limiter.Limiter
func main() {
db, err = sql.Open("mysql", "root:admin@/limiter?charset=utf8")
if err != nil {
panic(err)
}
l = &limiter.Limiter{
Interval: time.Minute,
Limit: 60,
Store: db,
}
l.Init()
http.HandleFunc("/hit", l.Handler)
http.ListenAndServe(":8080", nil)
}
```
### As Custom Gin Middleware

Loading…
Cancel
Save