Skip to content

Commit 60a328a

Browse files
johanbrandhorstachew22
authored andcommitted
Revert #708 since it breaks backwards compatibility
The solution for #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 #760.
1 parent 8077515 commit 60a328a

File tree

3 files changed

+5
-24
lines changed

3 files changed

+5
-24
lines changed

runtime/mux.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
package runtime
22

33
import (
4+
"context"
45
"fmt"
56
"net/http"
67
"strings"
7-
"context"
88

99
"github.com/golang/protobuf/proto"
1010
"google.golang.org/grpc/codes"

runtime/mux_test.go

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -183,30 +183,20 @@ func TestMuxServeHTTP(t *testing.T) {
183183
ops: []int{int(utilities.OpLitPush), 0, int(utilities.OpPush), 0, int(utilities.OpConcatN), 1, int(utilities.OpCapture), 1},
184184
pool: []string{"foo", "id"},
185185
},
186-
},
187-
reqMethod: "GET",
188-
reqPath: "/foo/bar",
189-
headers: map[string]string{
190-
"Content-Type": "application/json",
191-
},
192-
respStatus: http.StatusOK,
193-
respContent: "GET /foo/{id=*}",
194-
},
195-
{
196-
patterns: []stubPattern{
197186
{
198187
method: "GET",
199188
ops: []int{int(utilities.OpLitPush), 0, int(utilities.OpPush), 0, int(utilities.OpConcatN), 1, int(utilities.OpCapture), 1},
200189
pool: []string{"foo", "id"},
190+
verb: "verb",
201191
},
202192
},
203193
reqMethod: "GET",
204-
reqPath: "/foo/bar:123",
194+
reqPath: "/foo/bar:verb",
205195
headers: map[string]string{
206196
"Content-Type": "application/json",
207197
},
208198
respStatus: http.StatusOK,
209-
respContent: "GET /foo/{id=*}",
199+
respContent: "GET /foo/{id=*}:verb",
210200
},
211201
} {
212202
mux := runtime.NewServeMux()

runtime/pattern.go

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -144,16 +144,7 @@ func MustPattern(p Pattern, err error) Pattern {
144144
// If otherwise, the function returns an error.
145145
func (p Pattern) Match(components []string, verb string) (map[string]string, error) {
146146
if p.verb != verb {
147-
if p.verb != "" {
148-
return nil, ErrNotMatch
149-
}
150-
if len(components) == 0 {
151-
components = []string{":" + verb}
152-
} else {
153-
components = append([]string{}, components...)
154-
components[len(components)-1] += ":" + verb
155-
}
156-
verb = ""
147+
return nil, ErrNotMatch
157148
}
158149

159150
var pos int

0 commit comments

Comments
 (0)