Skip to content

Commit

Permalink
feat: support function route methods field
Browse files Browse the repository at this point in the history
  • Loading branch information
Skn0tt committed Aug 22, 2023
1 parent 3f74ec0 commit b930d21
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 5 deletions.
54 changes: 54 additions & 0 deletions go/models/function_route.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions go/porcelain/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -799,6 +799,7 @@ func bundleFromManifest(ctx context.Context, manifestFile *os.File, observer Dep
Pattern: route.Pattern,
Literal: route.Literal,
Expression: route.Expression,
Methods: route.Methods,
}
}

Expand Down
4 changes: 3 additions & 1 deletion go/porcelain/deploy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,8 @@ func TestBundleWithManifest(t *testing.T) {
},
{
"pattern": "/products/:id",
"expression": "^/products/(.*)$"
"expression": "^/products/(.*)$",
"methods": ["GET", "POST"]
}
]
},
Expand Down Expand Up @@ -525,6 +526,7 @@ func TestBundleWithManifest(t *testing.T) {
assert.Equal(t, "/products/:id", helloJSConfig.Routes[1].Pattern)
assert.Empty(t, helloJSConfig.Routes[1].Literal)
assert.Equal(t, "^/products/(.*)$", helloJSConfig.Routes[1].Expression)
assert.Equal(t, []string{"GET", "POST"}, helloJSConfig.Routes[1].Methods)
}

func TestReadZipRuntime(t *testing.T) {
Expand Down
7 changes: 4 additions & 3 deletions go/porcelain/functions_manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ type functionsManifestEntry struct {
}

type functionRoute struct {
Pattern string `json:"pattern"`
Literal string `json:"literal"`
Expression string `json:"expression"`
Pattern string `json:"pattern"`
Literal string `json:"literal"`
Expression string `json:"expression"`
Methods []string `json:"methods"`
}
7 changes: 6 additions & 1 deletion swagger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3632,7 +3632,12 @@ definitions:
literal:
type: string
expression:
type: string
type: string
methods:
type: array
items:
type: string
enum: ['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'OPTIONS']
parameters:
page:
type: integer
Expand Down

0 comments on commit b930d21

Please sign in to comment.