Add auth support
parent
13e8e625af
commit
5edfd81831
@ -1,6 +0,0 @@
|
||||
SPDXVersion: SPDX-2.1
|
||||
DataLicense: CC0-1.0
|
||||
Creator: René Jochum (rene@jochum.dev)
|
||||
PackageName: jochum.dev/jo-micro/router
|
||||
PackageOriginator: René Jochum
|
||||
PackageLicenseDeclared: Apache-2.0 OR GPL-2.0-or-later
|
@ -1,25 +1,10 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
_ "github.com/go-micro/plugins/v4/broker/kafka"
|
||||
_ "github.com/go-micro/plugins/v4/broker/mqtt"
|
||||
_ "github.com/go-micro/plugins/v4/broker/nats"
|
||||
_ "github.com/go-micro/plugins/v4/broker/rabbitmq"
|
||||
_ "github.com/go-micro/plugins/v4/broker/redis"
|
||||
|
||||
_ "github.com/go-micro/plugins/v4/registry/consul"
|
||||
_ "github.com/go-micro/plugins/v4/registry/etcd"
|
||||
_ "github.com/go-micro/plugins/v4/registry/eureka"
|
||||
_ "github.com/go-micro/plugins/v4/registry/gossip"
|
||||
_ "github.com/go-micro/plugins/v4/registry/kubernetes"
|
||||
_ "github.com/go-micro/plugins/v4/registry/nacos"
|
||||
_ "github.com/go-micro/plugins/v4/registry/nats"
|
||||
_ "github.com/go-micro/plugins/v4/registry/zookeeper"
|
||||
|
||||
_ "github.com/go-micro/plugins/v4/transport/grpc"
|
||||
_ "github.com/go-micro/plugins/v4/transport/http"
|
||||
_ "github.com/go-micro/plugins/v4/transport/nats"
|
||||
_ "github.com/go-micro/plugins/v4/transport/rabbitmq"
|
||||
_ "github.com/go-micro/plugins/v4/transport/tcp"
|
||||
_ "github.com/go-micro/plugins/v4/transport/utp"
|
||||
|
||||
_ "jochum.dev/jo-micro/auth/plugins/router/jwt"
|
||||
)
|
||||
|
@ -1,21 +0,0 @@
|
||||
package util
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"go-micro.dev/v4/metadata"
|
||||
)
|
||||
|
||||
// CtxFromRequest adds HTTP request headers to the context as metadata
|
||||
func CtxFromRequest(c *gin.Context, r *http.Request) context.Context {
|
||||
md := make(metadata.Metadata, len(r.Header)+1)
|
||||
for k, v := range r.Header {
|
||||
// The space here is wanted spaces are not allowed in HTTP header fields.
|
||||
md["PROXY "+strings.Replace(k, " ", "_", -1)] = strings.Join(v, ",")
|
||||
}
|
||||
|
||||
return metadata.MergeContext(c, md, true)
|
||||
}
|
Loading…
Reference in New Issue