Skip to content

Commit

Permalink
chore: rename metadata to endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
TBXark committed Nov 6, 2024
1 parent 327b4f4 commit 53024ef
Show file tree
Hide file tree
Showing 12 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion api/api/v1/auth_sphere.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion api/api/v1/system_sphere.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion api/api/v1/user_sphere.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion api/dash/v1/admin_sphere.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion api/dash/v1/auth_sphere.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion api/dash/v1/system_sphere.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion api/dash/v1/task_sphere.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion api/shared/v1/storage_sphere.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion api/shared/v1/test_sphere.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion contrib/protoc-gen-sphere/template.go.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
const Operation{{$svrType}}{{.OriginalName}} = "/{{$svrName}}/{{.OriginalName}}"
{{- end}}

var Metadata{{.ServiceType}} = [...][3]string{
var Endpoints{{.ServiceType}} = [...][3]string{
{{- range .Methods}}
{Operation{{$svrType}}{{.OriginalName}}, "{{.Method}}", "{{.GinPath}}" },
{{- end}}
Expand Down
2 changes: 1 addition & 1 deletion internal/server/dash/web.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func (w *Web) Run() error {
selector.MatchFunc(
ginx.MatchOperation(
authRoute.BasePath(),
dashv1.MetadataAuthService[:],
dashv1.EndpointsAuthService[:],
dashv1.OperationAuthServiceAuthLogin,
),
),
Expand Down
8 changes: 4 additions & 4 deletions pkg/server/ginx/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ package ginx

import "github.com/gin-gonic/gin"

func metadataToMatches(base string, metadata ...[][3]string) map[string]map[string]string {
func EndpointsToMatches(base string, endpoints ...[][3]string) map[string]map[string]string {
matches := make(map[string]map[string]string)
for _, list := range metadata {
for _, list := range endpoints {
for _, route := range list {
if _, ok := matches[route[1]]; !ok {
matches[route[1]] = make(map[string]string)
Expand All @@ -15,8 +15,8 @@ func metadataToMatches(base string, metadata ...[][3]string) map[string]map[stri
return matches
}

func MatchOperation(base string, metadata [][3]string, operations ...string) func(ctx *gin.Context) bool {
matches := metadataToMatches(base, metadata)
func MatchOperation(base string, endpoints [][3]string, operations ...string) func(ctx *gin.Context) bool {
matches := EndpointsToMatches(base, endpoints)
opts := make(map[string]struct{}, len(operations))
for _, opt := range operations {
opts[opt] = struct{}{}
Expand Down

0 comments on commit 53024ef

Please sign in to comment.