Skip to content

Commit 79a4012

Browse files
fix(framework): FunctionInvoker sets the request path (#22)
* [framework] FunctionInvoker sets the request path to the incoming event one. * [framework] Invoker path test uses instead of * Update framework/core/invoker_test.go --------- Co-authored-by: Thomas TACQUET <[email protected]>
1 parent e70d25e commit 79a4012

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

framework/core/invoker.go

+2
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ func (fn *FunctionInvoker) StreamRequest(reqBody CoreRuntimeRequest) (*http.Requ
9191
return nil, err
9292
}
9393

94+
request.URL.Path = event.Path
95+
9496
for key, values := range event.Headers {
9597
request.Header.Set(key, values)
9698
}

framework/core/invoker_test.go

+19
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,25 @@ func TestStreamRequestUserAgent(t *testing.T) {
5454
assert.NotNil(t, invoker)
5555
}
5656

57+
func TestExecutePath(t *testing.T) {
58+
t.Parallel()
59+
60+
const path = "/test/path"
61+
original, err := http.NewRequestWithContext(context.Background(), http.MethodGet, path, http.NoBody)
62+
require.NoError(t, err)
63+
assert.Equal(t, path, original.URL.Path)
64+
65+
invoker, err := NewInvoker("", "", "", "", "", false)
66+
require.NoError(t, err)
67+
assert.NotNil(t, invoker)
68+
69+
event := FormatEventHTTP(original, nil)
70+
req, err := invoker.Execute(event, GetExecutionContext(), TriggerTypeHTTP)
71+
require.NoError(t, err)
72+
assert.NotNil(t, req)
73+
assert.Equal(t, original.URL.Path, req.URL.Path)
74+
}
75+
5776
func TestStreamExecute(t *testing.T) {
5877
t.Parallel()
5978

0 commit comments

Comments
 (0)