From d4097af627c79f200b574a6976884b04212d4487 Mon Sep 17 00:00:00 2001 From: kevin Date: Wed, 12 Aug 2020 12:12:31 +0800 Subject: [PATCH] export token parser for refresh token service --- rest/handler/authhandler.go | 4 ++-- rest/{internal => token}/tokenparser.go | 2 +- rest/{internal => token}/tokenparser_test.go | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) rename rest/{internal => token}/tokenparser.go (99%) rename rest/{internal => token}/tokenparser_test.go (99%) diff --git a/rest/handler/authhandler.go b/rest/handler/authhandler.go index 253dc503..5ed6caf1 100644 --- a/rest/handler/authhandler.go +++ b/rest/handler/authhandler.go @@ -8,7 +8,7 @@ import ( "github.com/dgrijalva/jwt-go" "github.com/tal-tech/go-zero/core/logx" - "github.com/tal-tech/go-zero/rest/internal" + "github.com/tal-tech/go-zero/rest/token" ) const ( @@ -43,7 +43,7 @@ func Authorize(secret string, opts ...AuthorizeOption) func(http.Handler) http.H opt(&authOpts) } - parser := internal.NewTokenParser() + parser := token.NewTokenParser() return func(next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { token, err := parser.ParseToken(r, secret, authOpts.PrevSecret) diff --git a/rest/internal/tokenparser.go b/rest/token/tokenparser.go similarity index 99% rename from rest/internal/tokenparser.go rename to rest/token/tokenparser.go index d2eb9436..f2927b16 100644 --- a/rest/internal/tokenparser.go +++ b/rest/token/tokenparser.go @@ -1,4 +1,4 @@ -package internal +package token import ( "net/http" diff --git a/rest/internal/tokenparser_test.go b/rest/token/tokenparser_test.go similarity index 99% rename from rest/internal/tokenparser_test.go rename to rest/token/tokenparser_test.go index d486adcc..215b4db5 100644 --- a/rest/internal/tokenparser_test.go +++ b/rest/token/tokenparser_test.go @@ -1,4 +1,4 @@ -package internal +package token import ( "net/http"