Skip to content

Commit 650ddc1

Browse files
authored
Merge pull request #22 from microsoftgraph/bugfix/middleware-pipeline
single execution middleware pipeline fix
2 parents 55ab1b4 + 9cd134e commit 650ddc1

8 files changed

+24
-12
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1111

1212
### Changed
1313

14+
## [0.0.5] - 2021-12-02
15+
16+
### Changed
17+
18+
- Fixes a bug where the middleware pipeline would run only on the first request of the client/adapter/http client.
19+
1420
## [0.0.4] - 2021-12-01
1521

1622
### Changed

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ go 1.17
44

55
require (
66
github.com/google/uuid v1.3.0
7-
github.com/microsoft/kiota/abstractions/go v0.0.0-20211201125630-3501743a5dc5
8-
github.com/microsoft/kiota/http/go/nethttp v0.0.0-20211130101617-a4871ba0f35f
7+
github.com/microsoft/kiota/abstractions/go v0.0.0-20211202082735-099f3c37853a
8+
github.com/microsoft/kiota/http/go/nethttp v0.0.0-20211203130928-8449c9e67101
99
github.com/stretchr/testify v1.7.0
1010
)
1111

go.sum

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,16 @@ github.com/microsoft/kiota/abstractions/go v0.0.0-20211130101617-a4871ba0f35f h1
1414
github.com/microsoft/kiota/abstractions/go v0.0.0-20211130101617-a4871ba0f35f/go.mod h1:m37MbLdeSZ7DBzKtGI+GmlDSIybJBkKhsvLMqkYosb8=
1515
github.com/microsoft/kiota/abstractions/go v0.0.0-20211201125630-3501743a5dc5 h1:IL8rUlP+UMFRvL/bu26HkVMnhU7I5IWKciDIWOAQfEQ=
1616
github.com/microsoft/kiota/abstractions/go v0.0.0-20211201125630-3501743a5dc5/go.mod h1:m37MbLdeSZ7DBzKtGI+GmlDSIybJBkKhsvLMqkYosb8=
17+
github.com/microsoft/kiota/abstractions/go v0.0.0-20211202082735-099f3c37853a h1:c2vBeXjRwGJUL7aG1gHFwB+LpdDL20XKIOKQWKUoNQk=
18+
github.com/microsoft/kiota/abstractions/go v0.0.0-20211202082735-099f3c37853a/go.mod h1:m37MbLdeSZ7DBzKtGI+GmlDSIybJBkKhsvLMqkYosb8=
1719
github.com/microsoft/kiota/authentication/go/azure v0.0.0-20211201125630-3501743a5dc5 h1:d1ilFuzPOvADm4xiFHJ1SZ00SufAgyqfVXd3TCtS8c0=
1820
github.com/microsoft/kiota/authentication/go/azure v0.0.0-20211201125630-3501743a5dc5/go.mod h1:bmdumwBCIHlVdafcpHNNGzySN/v2mImqWTPgV1adBmA=
1921
github.com/microsoft/kiota/http/go/nethttp v0.0.0-20211130101617-a4871ba0f35f h1:1VRJ6bj+YljEUqXRf+MgPWdfJZf85/juVCwkS7GviZ8=
2022
github.com/microsoft/kiota/http/go/nethttp v0.0.0-20211130101617-a4871ba0f35f/go.mod h1:GHdBYJaaiuZKz78KcLSrjcin5FGXUK3e0wlX69NJMwE=
23+
github.com/microsoft/kiota/http/go/nethttp v0.0.0-20211202082735-099f3c37853a h1:w93KbR22weJ4CKHepKHkirx18j0XMShPWjSRn5ziMwA=
24+
github.com/microsoft/kiota/http/go/nethttp v0.0.0-20211202082735-099f3c37853a/go.mod h1:GHdBYJaaiuZKz78KcLSrjcin5FGXUK3e0wlX69NJMwE=
25+
github.com/microsoft/kiota/http/go/nethttp v0.0.0-20211203130928-8449c9e67101 h1:kTG9Tg52O2gNm8LzwyiPyjFendknhU4iqnylDjKQgNU=
26+
github.com/microsoft/kiota/http/go/nethttp v0.0.0-20211203130928-8449c9e67101/go.mod h1:GHdBYJaaiuZKz78KcLSrjcin5FGXUK3e0wlX69NJMwE=
2127
github.com/modocache/gover v0.0.0-20171022184752-b58185e213c5/go.mod h1:caMODM3PzxT8aQXRPkAt8xlV/e7d7w8GM5g0fa5F0D8=
2228
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
2329
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=

graph_odata_query_handler.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,11 @@ func NewGraphODataQueryHandlerWithOptions(options GraphODataQueryHandlerOptions)
5454
}
5555
}
5656

57-
func (middleware GraphODataQueryHandler) Intercept(pipeline khttp.Pipeline, req *nethttp.Request) (*nethttp.Response, error) {
57+
func (middleware GraphODataQueryHandler) Intercept(pipeline khttp.Pipeline, middlewareIndex int, req *nethttp.Request) (*nethttp.Response, error) {
5858
reqOption, ok := req.Context().Value(keyValue).(graphODataQueryHandlerOptionsInt)
5959
if ok && reqOption.GetShouldReplace()(req) || !ok && middleware.handlerOptions.ShouldReplace(req) {
6060
req.URL.RawQuery = middleware.regex.ReplaceAllString("?"+req.URL.RawQuery, "$1$$$2=")[1:]
6161
// inserting and removing the ? sign so we can make no dollar mandatory and avoid adding a second dollar when already here
6262
}
63-
return pipeline.Next(req)
63+
return pipeline.Next(req, middlewareIndex)
6464
}

graph_odata_query_handler_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ func TestItReplacesQueryParameters(t *testing.T) {
2323
if err != nil {
2424
t.Error(err)
2525
}
26-
resp, err := handler.Intercept(newNoopPipeline(), req)
26+
resp, err := handler.Intercept(newNoopPipeline(), 0, req)
2727
if err != nil {
2828
t.Error(err)
2929
}

graph_telemetry_handler.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ func NewGraphTelemetryHandler(options *GraphClientOptions) *GraphTelemetryHandle
4343
sdkVersion: serviceVersionPrefix + "graph-go-core/" + CoreVersion + featuresSuffix,
4444
}
4545
}
46-
func (middleware GraphTelemetryHandler) Intercept(pipeline khttp.Pipeline, req *nethttp.Request) (*nethttp.Response, error) {
46+
func (middleware GraphTelemetryHandler) Intercept(pipeline khttp.Pipeline, middlewareIndex int, req *nethttp.Request) (*nethttp.Response, error) {
4747
req.Header.Add("SdkVersion", middleware.sdkVersion)
4848
req.Header.Add("client-request-id", uuid.NewString())
49-
return pipeline.Next(req)
49+
return pipeline.Next(req, middlewareIndex)
5050
}

graph_telemetry_handler_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ type NoopPipeline struct {
1212
client *nethttp.Client
1313
}
1414

15-
func (pipeline *NoopPipeline) Next(req *nethttp.Request) (*nethttp.Response, error) {
15+
func (pipeline *NoopPipeline) Next(req *nethttp.Request, middlewareIndex int) (*nethttp.Response, error) {
1616
return pipeline.client.Do(req)
1717
}
1818
func newNoopPipeline() *NoopPipeline {
@@ -39,7 +39,7 @@ func TestItAddsHeaders(t *testing.T) {
3939
if err != nil {
4040
t.Error(err)
4141
}
42-
resp, err := handler.Intercept(newNoopPipeline(), req)
42+
resp, err := handler.Intercept(newNoopPipeline(), 0, req)
4343
if err != nil {
4444
t.Error(err)
4545
}
@@ -66,7 +66,7 @@ func TestItAddsServiceLibInfo(t *testing.T) {
6666
if err != nil {
6767
t.Error(err)
6868
}
69-
resp, err := handler.Intercept(newNoopPipeline(), req)
69+
resp, err := handler.Intercept(newNoopPipeline(), 0, req)
7070
if err != nil {
7171
t.Error(err)
7272
}
@@ -90,7 +90,7 @@ func TestItAddsServiceInfo(t *testing.T) {
9090
if err != nil {
9191
t.Error(err)
9292
}
93-
resp, err := handler.Intercept(newNoopPipeline(), req)
93+
resp, err := handler.Intercept(newNoopPipeline(), 0, req)
9494
if err != nil {
9595
t.Error(err)
9696
}

version.go

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

3-
var CoreVersion = "0.0.4"
3+
var CoreVersion = "0.0.5"

0 commit comments

Comments
 (0)