Skip to content

Commit

Permalink
Implement last-match-wins behaviour in mux
Browse files Browse the repository at this point in the history
In accordance with the http.proto spec, we should
use last-match-wins to determine which handler
is chosen if two are matched.

See #224
for more discussion.
  • Loading branch information
johanbrandhorst committed May 23, 2020
1 parent e090d4a commit 5bca97b
Show file tree
Hide file tree
Showing 24 changed files with 420 additions and 488 deletions.
80 changes: 40 additions & 40 deletions examples/internal/clients/abe/api/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1189,46 +1189,6 @@ paths:
description: "An unexpected error response"
schema:
$ref: "#/definitions/rpcStatus"
/v1/example/a_bit_of_everything/{singleNested.name}:
post:
tags:
- "ABitOfEverythingService"
operationId: "ABitOfEverythingService_DeepPathEcho"
parameters:
- name: "singleNested.name"
in: "path"
description: "name is nested field."
required: true
type: "string"
x-exportParamName: "SingleNestedName"
- in: "body"
name: "body"
required: true
schema:
$ref: "#/definitions/examplepbABitOfEverything"
x-exportParamName: "Body"
responses:
200:
description: "A successful response."
schema:
$ref: "#/definitions/examplepbABitOfEverything"
403:
description: "Returned when the user does not have permission to access\
\ the resource."
schema: {}
404:
description: "Returned when the resource does not exist."
schema:
type: "string"
format: "string"
418:
description: "I'm a teapot."
schema:
$ref: "#/definitions/examplepbNumericEnum"
default:
description: "An unexpected error response"
schema:
$ref: "#/definitions/rpcStatus"
/v1/example/a_bit_of_everything/{uuid}:
get:
tags:
Expand Down Expand Up @@ -1527,6 +1487,46 @@ paths:
description: "An unexpected error response"
schema:
$ref: "#/definitions/rpcStatus"
/v1/example/deep_path/{singleNested.name}:
post:
tags:
- "ABitOfEverythingService"
operationId: "ABitOfEverythingService_DeepPathEcho"
parameters:
- name: "singleNested.name"
in: "path"
description: "name is nested field."
required: true
type: "string"
x-exportParamName: "SingleNestedName"
- in: "body"
name: "body"
required: true
schema:
$ref: "#/definitions/examplepbABitOfEverything"
x-exportParamName: "Body"
responses:
200:
description: "A successful response."
schema:
$ref: "#/definitions/examplepbABitOfEverything"
403:
description: "Returned when the user does not have permission to access\
\ the resource."
schema: {}
404:
description: "Returned when the resource does not exist."
schema:
type: "string"
format: "string"
418:
description: "I'm a teapot."
schema:
$ref: "#/definitions/examplepbNumericEnum"
default:
description: "An unexpected error response"
schema:
$ref: "#/definitions/rpcStatus"
/v2/example/a_bit_of_everything/{abe.uuid}:
put:
tags:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1135,7 +1135,7 @@ func (a *ABitOfEverythingServiceApiService) ABitOfEverythingServiceDeepPathEcho(
)

// create path and map variables
localVarPath := a.client.cfg.BasePath + "/v1/example/a_bit_of_everything/{singleNested.name}"
localVarPath := a.client.cfg.BasePath + "/v1/example/deep_path/{singleNested.name}"
localVarPath = strings.Replace(localVarPath, "{"+"singleNested.name"+"}", fmt.Sprintf("%v", singleNestedName), -1)

localVarHeaderParams := make(map[string]string)
Expand Down
20 changes: 10 additions & 10 deletions examples/internal/helloworld/helloworld.pb.gw.go

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

2 changes: 1 addition & 1 deletion examples/internal/integration/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1053,7 +1053,7 @@ func testABEBulkEcho(t *testing.T, port int) {
go func() {
defer wg.Done()
defer reqw.Close()
for i := 0; i < 1000; i++ {
for i := 0; i < 10; i++ {
s := fmt.Sprintf("message %d", i)
msg := sub.StringMessage{Value: &s}
buf, err := marshaler.Marshal(&msg)
Expand Down
Loading

0 comments on commit 5bca97b

Please sign in to comment.