Skip to content

Commit 5bf0775

Browse files
committed
chore: exposed barf.SubRoute for all RetroFrame instance
1 parent b614a13 commit 5bf0775

3 files changed

Lines changed: 8 additions & 1 deletion

File tree

example/subroute/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ func main() {
5252
})
5353

5454
// create a subrouter (retroframe)
55-
r := barf.RetroFrame("/api/v1")
55+
var r *barf.SubRoute = barf.RetroFrame("/api/v1")
5656

5757
// apply middleware to subrouter. note that the only difference between this and global middlewares is that you need to pass the
5858
barf.Hippocampus(r).Hijack(func(h http.Handler) http.Handler {

middleware.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package barf
22

33
import (
44
"github.com/opensaucerer/barf/router"
5+
"github.com/opensaucerer/barf/typing"
56
)
67

78
/*
@@ -10,3 +11,6 @@ Hippocampus prepares the given barf router or base barf handler for hijacking. T
1011
Note: the base barf handler is the one that is created by the barf.Stark() function and can only be hijacked before the barf.Beck() function is called.
1112
*/
1213
var Hippocampus = router.Hippocampus
14+
15+
// Middleware is the type of a function that can be used as a barf middleware.
16+
type Middleware = typing.Middleware

route.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,6 @@ var Any = router.Any
2828

2929
// RetroFrame returns a new RetroFrame instance registered against the given entry path.
3030
var RetroFrame = router.RetroFrame
31+
32+
// SubRoute is the type of a barf RetroFrame instance.
33+
type SubRoute = router.SubRoute

0 commit comments

Comments
 (0)