vapor route

作者: 搞好关系 | 来源:发表于2018-10-04 23:09 被阅读3次

    Register 路由注册

        let router = EngineRouter.default()
        try routes(router)
        services.register(router, as: Router.self)
    

    Parameter

    /users/:user_id

        // Create a route for /users/:user_id
    let user = Route(path: [.constant("users"), .parameter("user_id")], output: ...)
    
    // Create a router and register our route
    let router = TrieRouter(...)
    router.register(route: user)
    
    // Create empty Parameters to hold dynamic values
    var params = Parameters()
    
    // Route the path /users/42
    _ = router.route(path: ["users", "42"], parameters: &params)
    
    // The params contains our dynamic value!
    print(params) // ["user_id": "42"]
    

    相关文章

      网友评论

        本文标题:vapor route

        本文链接:https://www.haomeiwen.com/subject/znpwoftx.html