Browse Source

docs: fix indent

master
evanchen333 6 months ago
parent
commit
76393ad58b
  1. 10
      README.md
  2. 1
      example/main.go

10
README.md

@ -5,7 +5,7 @@ The counting of the rate is based on the hits within the past **interval**
## Start
Run `go run example/main.go` and `curl http://localhost:8080/hit`.
Run `go run example/main.go` and `curl http://localhost:8080/hit`. (Default 60 hits per minute, and uses in-memory sqlite as database)
## Limiter Usage
@ -19,12 +19,12 @@ func main() {
// Limiter settings can be changed
// for example:
// l.Interval = time.Minute * 10
// l.Interval = time.Minute * 10
// l.Limit = 5
http.HandleFunc("/hit", l.Handler)
http.ListenAndServe(":8080", nil)
http.ListenAndServe(":8080", nil)
}
```
@ -33,7 +33,7 @@ func main() {
```go
func RateLimit() gin.HandlerFunc {
l := limiter.Default()
return func(c *gin.Context) {
return func(c *gin.Context) {
ip := c.Header.Get("X-Real-Ip")
if ip == "" {
ip = c.Header.Get("X-Forwarded-For")
@ -47,6 +47,6 @@ func RateLimit() gin.HandlerFunc {
} else {
c.Next()
}
}
}
}
```

1
example/main.go

@ -32,7 +32,6 @@ func main() {
l.Init()
} else {
l = limiter.Default()
l.Limit = 5
}
http.HandleFunc("/hit", l.Handler)

Loading…
Cancel
Save