Set value in context, not metadata
This commit is contained in:
parent
774c0d30a7
commit
574bf5ac69
@ -1,15 +1,13 @@
|
|||||||
package auth
|
package auth
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/micro/go-micro/v2/metadata"
|
|
||||||
|
|
||||||
"github.com/micro/go-micro/v2/api/resolver"
|
"github.com/micro/go-micro/v2/api/resolver"
|
||||||
"github.com/micro/go-micro/v2/api/resolver/path"
|
"github.com/micro/go-micro/v2/api/resolver/path"
|
||||||
"github.com/micro/go-micro/v2/auth"
|
"github.com/micro/go-micro/v2/auth"
|
||||||
@ -93,10 +91,8 @@ func (h authHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
|||||||
} else if err == nil {
|
} else if err == nil {
|
||||||
// set the endpoint in the context so it can be used to resolve
|
// set the endpoint in the context so it can be used to resolve
|
||||||
// the request later
|
// the request later
|
||||||
if bytes, err := json.Marshal(endpoint); err == nil {
|
ctx := context.WithValue(req.Context(), resolver.Endpoint{}, endpoint)
|
||||||
ctx := metadata.Set(req.Context(), "endpoint", string(bytes))
|
*req = *req.WithContext(ctx)
|
||||||
*req = *req.WithContext(ctx)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// construct the resource name, e.g. home => go.micro.web.home
|
// construct the resource name, e.g. home => go.micro.web.home
|
||||||
|
Loading…
Reference in New Issue
Block a user