Skip to content

Commit

Permalink
Upgrade Dependencies + Add MethodDesc Getter from Context (#46)
Browse files Browse the repository at this point in the history
* bump deps, add context getter for MethodDesc

* bump go versions

* fix method name

* lint fix
  • Loading branch information
pquerna committed Jun 18, 2024
1 parent 18db6db commit beb667e
Show file tree
Hide file tree
Showing 1,556 changed files with 382,937 additions and 102,198 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@v4
with:
go-version: 1.20.x
go-version: 1.22.x
- name: Checkout code
uses: actions/checkout@v3
- name: Run linters
Expand All @@ -18,7 +18,7 @@ jobs:
go-test:
strategy:
matrix:
go-version: [1.20.x]
go-version: [1.22.x]
platform: [ubuntu-latest]
runs-on: ${{ matrix.platform }}
steps:
Expand Down
44 changes: 0 additions & 44 deletions apigw/go.sum

This file was deleted.

19 changes: 19 additions & 0 deletions apigw/v1/http_bridge.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package v1

import (
"context"
"fmt"
"net/http"
"strings"
Expand All @@ -11,6 +12,24 @@ import (
"google.golang.org/grpc/peer"
)

type contextKey string

func (c contextKey) String() string {
return "apigw_v1 context key " + string(c)
}

const (
contextKeyMethodDesc = contextKey("methodDesc")
)

func MethodDescContext(ctx context.Context) *MethodDesc {
return ctx.Value(contextKeyMethodDesc).(*MethodDesc)
}

func NewMethodDescContext(ctx context.Context, methodDesc *MethodDesc) context.Context {
return context.WithValue(ctx, contextKeyMethodDesc, methodDesc)
}

func MetadataForRequest(req *http.Request, methodFulLName string) metadata.MD {
// https://github.com/grpc/grpc/blob/master/doc/PROTOCOL-HTTP2.md
rv := metadata.MD{}
Expand Down
25 changes: 13 additions & 12 deletions example/openapitest/openapi_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
validator "github.com/pb33f/libopenapi-validator"
dm_base "github.com/pb33f/libopenapi/datamodel/high/base"
dm_v3 "github.com/pb33f/libopenapi/datamodel/high/v3"
"github.com/pb33f/libopenapi/orderedmap"
"github.com/stretchr/testify/require"
)

Expand All @@ -25,37 +26,37 @@ func TestOpenAPISpec(t *testing.T) {
Version: "1.0.0",
},
Paths: &dm_v3.Paths{
PathItems: map[string]*dm_v3.PathItem{
PathItems: orderedmap.ToOrderedMap(map[string]*dm_v3.PathItem{
"/shelves": {
Get: &dm_v3.Operation{
OperationId: bookstore_v1.BookstoreService_ListShelves_FullMethodName,
Parameters: []*dm_v3.Parameter{},
Responses: &dm_v3.Responses{
Codes: map[string]*dm_v3.Response{
Codes: orderedmap.ToOrderedMap(map[string]*dm_v3.Response{
"200": {
Description: "OK",
Content: map[string]*dm_v3.MediaType{
Content: orderedmap.ToOrderedMap(map[string]*dm_v3.MediaType{
"application/json": {
Schema: listShelvesResponseRef,
},
},
}),
},
},
}),
},
},
},
},
}),
},
Servers: []*dm_v3.Server{
{
URL: "https://api.example.com",
},
},
Components: &dm_v3.Components{
Schemas: map[string]*dm_base.SchemaProxy{
Schemas: orderedmap.ToOrderedMap(map[string]*dm_base.SchemaProxy{
"Shelf": dm_base.CreateSchemaProxy(&dm_base.Schema{
Type: []string{"object"},
Properties: map[string]*dm_base.SchemaProxy{
Properties: orderedmap.ToOrderedMap(map[string]*dm_base.SchemaProxy{
"id": dm_base.CreateSchemaProxy(&dm_base.Schema{
Type: []string{"integer"},
Format: "int64",
Expand All @@ -69,22 +70,22 @@ func TestOpenAPISpec(t *testing.T) {
`search%5Bencoded%5D`: dm_base.CreateSchemaProxy(&dm_base.Schema{
Type: []string{"string"},
}),
},
}),
}),
"ListShelvesResponse": dm_base.CreateSchemaProxy(
&dm_base.Schema{
Type: []string{"object"},
Properties: map[string]*dm_base.SchemaProxy{
Properties: orderedmap.ToOrderedMap(map[string]*dm_base.SchemaProxy{
"shelves": dm_base.CreateSchemaProxy(
&dm_base.Schema{
Type: []string{"array"},
Items: &dm_base.DynamicValue[*dm_base.SchemaProxy, bool]{A: shelfRef},
},
),
},
}),
},
),
},
}),
},
}
y, err := doc.Render()
Expand Down
75 changes: 41 additions & 34 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,57 +1,64 @@
module github.com/ductone/protoc-gen-apigw

go 1.20
go 1.21

toolchain go1.22.4

require (
github.com/davecgh/go-spew v1.1.1
github.com/ductone/protoc-gen-apigw/routers/ginapi v0.0.0-20230719224916-5119b8509632
github.com/fatih/camelcase v1.0.0
github.com/gin-gonic/gin v1.9.1
github.com/gin-gonic/gin v1.10.0
github.com/grpc-ecosystem/go-grpc-middleware v1.4.0
github.com/lyft/protoc-gen-star v0.6.2
github.com/pb33f/libopenapi v0.9.4
github.com/pb33f/libopenapi-validator v0.0.10
github.com/stretchr/testify v1.8.3
github.com/pb33f/libopenapi v0.16.8
github.com/pb33f/libopenapi-validator v0.0.56
github.com/stretchr/testify v1.9.0
github.com/stuart-warren/yamlfmt v0.2.0
golang.org/x/text v0.11.0
google.golang.org/grpc v1.56.2
google.golang.org/protobuf v1.31.0
go.uber.org/zap v1.27.0
golang.org/x/text v0.16.0
google.golang.org/genproto/googleapis/rpc v0.0.0-20240617180043-68d350f18fd4
google.golang.org/grpc v1.64.0
google.golang.org/protobuf v1.34.2
gopkg.in/yaml.v3 v3.0.1
)

require (
github.com/bytedance/sonic v1.9.1 // indirect
github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 // indirect
github.com/bahlo/generic-list-go v0.2.0 // indirect
github.com/buger/jsonparser v1.1.1 // indirect
github.com/bytedance/sonic v1.11.8 // indirect
github.com/bytedance/sonic/loader v0.1.1 // indirect
github.com/cloudwego/base64x v0.1.4 // indirect
github.com/cloudwego/iasm v0.2.0 // indirect
github.com/dprotaso/go-yit v0.0.0-20220510233725-9ba8df137936 // indirect
github.com/gabriel-vasile/mimetype v1.4.2 // indirect
github.com/gabriel-vasile/mimetype v1.4.4 // indirect
github.com/gin-contrib/sse v0.1.0 // indirect
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/go-playground/validator/v10 v10.14.0 // indirect
github.com/goccy/go-json v0.10.2 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 // indirect
github.com/go-playground/validator/v10 v10.22.0 // indirect
github.com/goccy/go-json v0.10.3 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/cpuid/v2 v2.2.4 // indirect
github.com/leodido/go-urn v1.2.4 // indirect
github.com/mattn/go-isatty v0.0.19 // indirect
github.com/klauspost/cpuid/v2 v2.2.8 // indirect
github.com/leodido/go-urn v1.4.0 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/pelletier/go-toml/v2 v2.0.8 // indirect
github.com/pelletier/go-toml/v2 v2.2.2 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/santhosh-tekuri/jsonschema/v5 v5.2.0 // indirect
github.com/spf13/afero v1.9.5 // indirect
github.com/santhosh-tekuri/jsonschema/v5 v5.3.1 // indirect
github.com/spf13/afero v1.11.0 // indirect
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
github.com/ugorji/go/codec v1.2.11 // indirect
github.com/ugorji/go/codec v1.2.12 // indirect
github.com/vmware-labs/yaml-jsonpath v0.3.2 // indirect
go.uber.org/atomic v1.11.0 // indirect
github.com/wk8/go-ordered-map/v2 v2.1.8 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.24.0 // indirect
golang.org/x/arch v0.3.0 // indirect
golang.org/x/crypto v0.11.0 // indirect
golang.org/x/mod v0.12.0 // indirect
golang.org/x/net v0.12.0 // indirect
golang.org/x/sync v0.3.0 // indirect
golang.org/x/sys v0.10.0 // indirect
golang.org/x/tools v0.11.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20230720185612-659f7aaaa771 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
golang.org/x/arch v0.8.0 // indirect
golang.org/x/crypto v0.24.0 // indirect
golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8 // indirect
golang.org/x/mod v0.18.0 // indirect
golang.org/x/net v0.26.0 // indirect
golang.org/x/sync v0.7.0 // indirect
golang.org/x/sys v0.21.0 // indirect
golang.org/x/tools v0.22.0 // indirect
)
Loading

0 comments on commit beb667e

Please sign in to comment.