Skip to content

Commit 896f736

Browse files
committed
add field strict to use absolute paths with routing.
1 parent 637e2e0 commit 896f736

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

transpiler/transpiler_utils.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ func WrapEndpoint(path string, r samb.Route, h string) string {
1616
res := fmt.Sprintf(`
1717
if basePath := "%s"; strings.Contains(r.URL.Path , basePath) `, path+r.Path)
1818

19+
if r.Strict {
20+
res = fmt.Sprintf(`
21+
if basePath := "%s"; r.URL.Path == basePath `, path+r.Path)
22+
}
23+
1924
if r.Method != "" &&
2025
r.Method != "*" {
2126

types.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,11 @@ type Route struct {
6363
// with variables r and w in scope.
6464
Go Go
6565
Doc Documentation
66+
// Strict specifies
67+
// if route should only be invoked
68+
// if the request path matches this
69+
// routes' path
70+
Strict bool
6671
}
6772

6873
// Array of Go statements

0 commit comments

Comments
 (0)