Skip to content

Commit

Permalink
Revert grpc-ecosystem#708 since it breaks backwards compatibility
Browse files Browse the repository at this point in the history
The solution for grpc-ecosystem#224 turned out to break backwards
compatibility, so we're going to have to find another
solution for users who desire this behaviour.
Also adds test cases from grpc-ecosystem#760.
  • Loading branch information
johanbrandhorst authored and achew22 committed Oct 1, 2018
1 parent b02b8c2 commit c58bd50
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 24 deletions.
2 changes: 1 addition & 1 deletion runtime/mux.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package runtime

import (
"context"
"fmt"
"net/http"
"strings"
"context"

"github.com/golang/protobuf/proto"
"google.golang.org/grpc/codes"
Expand Down
16 changes: 3 additions & 13 deletions runtime/mux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,30 +183,20 @@ func TestMuxServeHTTP(t *testing.T) {
ops: []int{int(utilities.OpLitPush), 0, int(utilities.OpPush), 0, int(utilities.OpConcatN), 1, int(utilities.OpCapture), 1},
pool: []string{"foo", "id"},
},
},
reqMethod: "GET",
reqPath: "/foo/bar",
headers: map[string]string{
"Content-Type": "application/json",
},
respStatus: http.StatusOK,
respContent: "GET /foo/{id=*}",
},
{
patterns: []stubPattern{
{
method: "GET",
ops: []int{int(utilities.OpLitPush), 0, int(utilities.OpPush), 0, int(utilities.OpConcatN), 1, int(utilities.OpCapture), 1},
pool: []string{"foo", "id"},
verb: "verb",
},
},
reqMethod: "GET",
reqPath: "/foo/bar:123",
reqPath: "/foo/bar:verb",
headers: map[string]string{
"Content-Type": "application/json",
},
respStatus: http.StatusOK,
respContent: "GET /foo/{id=*}",
respContent: "GET /foo/{id=*}:verb",
},
} {
mux := runtime.NewServeMux()
Expand Down
11 changes: 1 addition & 10 deletions runtime/pattern.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,16 +144,7 @@ func MustPattern(p Pattern, err error) Pattern {
// If otherwise, the function returns an error.
func (p Pattern) Match(components []string, verb string) (map[string]string, error) {
if p.verb != verb {
if p.verb != "" {
return nil, ErrNotMatch
}
if len(components) == 0 {
components = []string{":" + verb}
} else {
components = append([]string{}, components...)
components[len(components)-1] += ":" + verb
}
verb = ""
return nil, ErrNotMatch
}

var pos int
Expand Down

0 comments on commit c58bd50

Please sign in to comment.