Skip to content

Instantly share code, notes, and snippets.

@kunjee17
Created July 24, 2018 11:50
Show Gist options
  • Save kunjee17/19a56866f95c93f71064b3033b933562 to your computer and use it in GitHub Desktop.
Save kunjee17/19a56866f95c93f71064b3033b933562 to your computer and use it in GitHub Desktop.
let topRouter = scope {
pipe_through headerPipe
not_found_handler (text "404")
get "/" helloWorld
get "/a" helloWorld2
getf "/name/%s" helloWorldName
getf "/name/%s/%i" helloWorldNameAge
//scopes can be defined inline to simulate `subRoute` combinator
forward "/other" (scope {
pipe_through otherHeaderPipe
not_found_handler (text "Other 404")
get "/" otherHelloWorld
get "/a" otherHelloWorld2
})
// or can be defined separatly and used as HttpHandler
forward "/api" apiRouter
// same with controllers
forward "/users" userController
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment