Skip to content

Commit a1934ad

Browse files
feat: add prefer_static to functions config (#515)
1 parent 8359c4e commit a1934ad

File tree

5 files changed

+19
-9
lines changed

5 files changed

+19
-9
lines changed

go/models/function_route.go

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

go/porcelain/deploy.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -818,10 +818,11 @@ func bundleFromManifest(ctx context.Context, manifestFile *os.File, observer Dep
818818
routes := make([]*models.FunctionRoute, len(function.Routes))
819819
for i, route := range function.Routes {
820820
routes[i] = &models.FunctionRoute{
821-
Pattern: route.Pattern,
822-
Literal: route.Literal,
823-
Expression: route.Expression,
824-
Methods: route.Methods,
821+
Pattern: route.Pattern,
822+
Literal: route.Literal,
823+
Expression: route.Expression,
824+
Methods: route.Methods,
825+
PreferStatic: route.PreferStatic,
825826
}
826827
}
827828

go/porcelain/deploy_test.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -652,7 +652,8 @@ func TestBundleWithManifest(t *testing.T) {
652652
"routes": [
653653
{
654654
"pattern": "/products",
655-
"literal": "/products"
655+
"literal": "/products",
656+
"prefer_static": true
656657
},
657658
{
658659
"pattern": "/products/:id",
@@ -707,9 +708,11 @@ func TestBundleWithManifest(t *testing.T) {
707708
assert.Equal(t, "/products", helloJSConfig.Routes[0].Pattern)
708709
assert.Equal(t, "/products", helloJSConfig.Routes[0].Literal)
709710
assert.Empty(t, helloJSConfig.Routes[0].Expression)
711+
assert.True(t, helloJSConfig.Routes[0].PreferStatic)
710712

711713
assert.Equal(t, "/products/:id", helloJSConfig.Routes[1].Pattern)
712714
assert.Empty(t, helloJSConfig.Routes[1].Literal)
715+
assert.False(t, helloJSConfig.Routes[1].PreferStatic)
713716
assert.Equal(t, "^/products/(.*)$", helloJSConfig.Routes[1].Expression)
714717
assert.Equal(t, []string{"GET", "POST"}, helloJSConfig.Routes[1].Methods)
715718
}

go/porcelain/functions_manifest.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,9 @@ type functionsManifestEntry struct {
2121
}
2222

2323
type functionRoute struct {
24-
Pattern string `json:"pattern"`
25-
Literal string `json:"literal"`
26-
Expression string `json:"expression"`
27-
Methods []string `json:"methods"`
24+
Pattern string `json:"pattern"`
25+
Literal string `json:"literal"`
26+
Expression string `json:"expression"`
27+
Methods []string `json:"methods"`
28+
PreferStatic bool `json:"prefer_static"`
2829
}

swagger.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3709,6 +3709,8 @@ definitions:
37093709
items:
37103710
type: string
37113711
enum: ['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'OPTIONS']
3712+
prefer_static:
3713+
type: boolean
37123714
parameters:
37133715
page:
37143716
type: integer

0 commit comments

Comments
 (0)