Auth is no more a WIP, Ratelimiter now uses memory:// by default

master
René Jochum 2 years ago
parent c06fd8b9b5
commit 65ec89ff19
Signed by: jochum
GPG Key ID: F7D906F5E51E8E5E

@ -6,10 +6,6 @@ A dynamic router (API Gatway) for go-micro.
It looks for services that host "internal/proto/routerclientpb/routerclientpb.RouterClientService" and ask's them for routes/endpoints, then it registers that endpoints via a proxy method within gin.
## AUTH is WORK IN PROGRESS
I'm still working on the implementation of jo-micro/auth2, everything Auth related my change.
## Caveats
- gin doesn't allow to delete routes, so if you want to delete a route you have to restart go-micro/router.

@ -8,11 +8,13 @@ import (
"io"
"net/http"
"strconv"
"strings"
"time"
libredis "github.com/go-redis/redis/v8"
limiter "github.com/ulule/limiter/v3"
"github.com/ulule/limiter/v3/drivers/store/memory"
sredis "github.com/ulule/limiter/v3/drivers/store/redis"
"github.com/gin-gonic/gin"
@ -53,7 +55,7 @@ func (h *Handler) Init(service micro.Service, engine *gin.Engine, routerAuth aut
h.routerAuth = routerAuth
globalGroup := h.engine.Group("")
if rlStoreURL != "" {
if strings.HasPrefix(rlStoreURL, "redis://") {
// Create a redis client.
option, err := libredis.ParseURL(rlStoreURL)
if err != nil {
@ -70,6 +72,8 @@ func (h *Handler) Init(service micro.Service, engine *gin.Engine, routerAuth aut
return err
}
h.rlStore = store
} else if rlStoreURL == "memory://" {
h.rlStore = memory.NewStore()
}
// Refresh routes for the proxy every 10 seconds

@ -116,8 +116,9 @@ func main() {
},
&cli.StringFlag{
Name: "router_ratelimiter_store_url",
Usage: "Ratelimiter store URL, for example redis://localhost:6379/0. No store = no Endpoints that require a ratelimiter",
Usage: "Ratelimiter store URL, for example redis://localhost:6379/0",
EnvVars: []string{"MICRO_ROUTER_RATELIMITER_STORE_URL"},
Value: "memory://",
},
})))

@ -17,7 +17,7 @@ require (
github.com/urfave/cli/v2 v2.16.3
go-micro.dev/v4 v4.8.1
google.golang.org/protobuf v1.28.1
jochum.dev/jo-micro/auth2 v0.3.1
jochum.dev/jo-micro/auth2 v0.3.2
)
require (

@ -313,3 +313,5 @@ gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
jochum.dev/jo-micro/auth2 v0.3.0 h1:7r9Vo7/Wlc/tB8sBN4BGQFniOy2x1ekoWI5I4+xBUv0=
jochum.dev/jo-micro/auth2 v0.3.0/go.mod h1:fSWMvxDct/jhmP1CC5HQTSfklqZRmygO8Zv5qZVuUHg=
jochum.dev/jo-micro/auth2 v0.3.1/go.mod h1:fSWMvxDct/jhmP1CC5HQTSfklqZRmygO8Zv5qZVuUHg=
jochum.dev/jo-micro/auth2 v0.3.2 h1:dWY7RPLS3/Sn7YWDz4Kl8Str6lzMXUdfbMBLJLXmehk=
jochum.dev/jo-micro/auth2 v0.3.2/go.mod h1:VRGDU1tsDrlEVN9ch3DlvhUslDTQGGp3KLReBRL6V1s=

Loading…
Cancel
Save