简体   繁体   English

router.ex中的scope是什么意思,是新发明的宏吗?

[英]what's the meaning of scope in the router.ex, is it a newly invented macro?

  scope "/", HelloWeb do
    pipe_through :browser

    get "/", PageController, :index
    get "/hello", HelloController, :index
  end

The scope is lowercase started, it is a variable or syntax keyword invented macro? scope是小写开头的,是变量还是语法关键字发明的宏? How to understand it?怎么理解?

scope is indeed a macro, just like pipe_through , get , post etc, as you can see in the documentation.scope确实是一个宏,就像pipe_throughgetpost等,正如您在文档中看到的那样。

Under the bonnet it creates the routes to dispatch a matching request to the correct controller action and it creates helper functions to generate links to these routes.在引擎盖下,它创建路由以将匹配请求发送到正确的 controller 操作,并创建辅助函数以生成指向这些路由的链接。

To understand it better, take a look at the documentation and/or the code .为了更好地理解它,请查看文档和/或代码

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM