Skip to content

Commit 76eae7f

Browse files
authored
Merge pull request #483 from netlify/functionroute-methods
feat: support function route `methods` field
2 parents 3f74ec0 + b930d21 commit 76eae7f

File tree

5 files changed

+68
-5
lines changed

5 files changed

+68
-5
lines changed

go/models/function_route.go

+54
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

go/porcelain/deploy.go

+1
Original file line numberDiff line numberDiff line change
@@ -799,6 +799,7 @@ func bundleFromManifest(ctx context.Context, manifestFile *os.File, observer Dep
799799
Pattern: route.Pattern,
800800
Literal: route.Literal,
801801
Expression: route.Expression,
802+
Methods: route.Methods,
802803
}
803804
}
804805

go/porcelain/deploy_test.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,8 @@ func TestBundleWithManifest(t *testing.T) {
480480
},
481481
{
482482
"pattern": "/products/:id",
483-
"expression": "^/products/(.*)$"
483+
"expression": "^/products/(.*)$",
484+
"methods": ["GET", "POST"]
484485
}
485486
]
486487
},
@@ -525,6 +526,7 @@ func TestBundleWithManifest(t *testing.T) {
525526
assert.Equal(t, "/products/:id", helloJSConfig.Routes[1].Pattern)
526527
assert.Empty(t, helloJSConfig.Routes[1].Literal)
527528
assert.Equal(t, "^/products/(.*)$", helloJSConfig.Routes[1].Expression)
529+
assert.Equal(t, []string{"GET", "POST"}, helloJSConfig.Routes[1].Methods)
528530
}
529531

530532
func TestReadZipRuntime(t *testing.T) {

go/porcelain/functions_manifest.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ type functionsManifestEntry struct {
2020
}
2121

2222
type functionRoute struct {
23-
Pattern string `json:"pattern"`
24-
Literal string `json:"literal"`
25-
Expression string `json:"expression"`
23+
Pattern string `json:"pattern"`
24+
Literal string `json:"literal"`
25+
Expression string `json:"expression"`
26+
Methods []string `json:"methods"`
2627
}

swagger.yml

+6-1
Original file line numberDiff line numberDiff line change
@@ -3632,7 +3632,12 @@ definitions:
36323632
literal:
36333633
type: string
36343634
expression:
3635-
type: string
3635+
type: string
3636+
methods:
3637+
type: array
3638+
items:
3639+
type: string
3640+
enum: ['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'OPTIONS']
36363641
parameters:
36373642
page:
36383643
type: integer

0 commit comments

Comments
 (0)