路由文件中的注释在控制台中打印

时间:2018-09-19 18:06:12

标签: playframework-2.6

我在routes文件中有一些条目和注释。

#new page, called when signup is clicked
#If I do /home/:signup then Angular gives error that empty path url segment cannot have parameters: ';signup=error'. It seems its
#because a url parameter (something which is preceded by ; and is generally a key/value pair like signup=error) can be part of a
#a path segment only (something which begins with a /
#Below matches the url /home;signup=error or home;signup=success. The rule for matching urls seem to be everything is matched
#exactly as mentioned unless special characters like :, * or reg exp is used.

GET     /home;signup=:result        controllers.HomeController.index(result)

index函数定义为

def index(signupMessage:String = "") = addToken {
        silhouette.UserAwareAction { implicit request =>
        println(s"index action called with request ${utilities.printPlayHttpRequest(request)}")
          //TODOM - fix as signup value is coming up as ;signup=error or ;signup=success instead of just success or error
        println(s"index page's argument "+signupMessage)
        val Token(name, value) = CSRF.getToken.get
        println(s"Token name ${name}, value ${value}")
        Ok(views.html.index(signupMessage,messagesApi("app.title")(langs.availables(0))))
      }
    }

我注意到,当应用程序启动并收到一个GET请求时,它会打印来自routes文件的注释!怎么来的?

identity: None 
 content type: None 
 accept languages: List(Lang(en_GB), Lang(en_US), Lang(en)) 
  acceptedTypes:  List(text/html, application/xhtml+xml, image/webp, image/apng, application/xml; q=0.9, */*; q=0.8) 
 authenticator: None 
 None 
 cookies: Map(CJCsrfCookie -> Cookie(CJCsrfCookie,0dad7e35eda57b84c357fd52c7b00856502e935b-1527945534855-278b8bc3fbe1c1e8aacf27d9,None,/,None,false,true,None)) 
 session: Session(Map()) 
 uri: / 
 secure: false 
 request: GET / raw query string:  
 path: / 
 id: 1 
 host: localhost:9000 
 Attr: {Session -> Container<Session(Map())>, TOKEN_INFO -> play.filters.csrf.CSRF$TokenInfo@203d6247, Tags -> Map(ROUTE_COMMENTS ->  An example controller showing a sample home page
If I don't pass signupMessage="" (even though the index function has a default value for the argument), then I get error
Using different overloaded methods is not allowed. If you are using a single method in combination with default parameters, make sure you declare them all explicitly., ROUTE_PATTERN -> /, ROUTE_CONTROLLER -> controllers.HomeController, ROUTE_ACTION_METHOD -> index, ROUTE_VERB -> GET), Cookies -> Container<Map(CJCsrfCookie -> Cookie(CJCsrfCookie,0dad7e35eda57b84c357fd52c7b00856502e935b-1527945534855-278b8bc3fbe1c1e8aacf27d9,None,/,None,false,true,None))>, HandlerDef -> HandlerDef(ReloadableClassLoader(v1){file:/C:/Users/manuc/Documents/manu/codingjedi/code_related/code/frontend/web/target/scala-2.12/classes/},router,controllers.HomeController,index,List(class java.lang.String),GET,/, An example controller showing a sample home page
If I don't pass signupMessage="" (even though the index function has a default value for the argument), then I get error
Using different overloaded methods is not allowed. If you are using a single method in combination with default parameters, make sure you declare them all explicitly.,List()), Flash -> Container<?>, Id -> 1}, 
 Body: AnyContentAsEmpty,  
 connection: RemoteAddress(0:0:0:0:0:0:0:1, secure=false, certs=None),  
 headers: List((Remote-Address,0:0:0:0:0:0:0:1:58307), (Raw-Request-URI,/), (Tls-Session-Info,[Session-1, SSL_NULL_WITH_NULL_NULL]), (Host,localhost:9000), (Connection,keep-alive), (Upgrade-Insecure-Requests,1), (User-Agent,Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36), (Accept,text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8), (Accept-Encoding,gzip, deflate, br), (Accept-Language,en-GB,en-US;q=0.9,en;q=0.8), (Cookie,CJCsrfCookie=0dad7e35eda57b84c357fd52c7b00856502e935b-1527945534855-278b8bc3fbe1c1e8aacf27d9), (Timeout-Access,<function1>)),  
 method: GET, 
 target:  play.core.server.akkahttp.AkkaModelConversion$$anon$2@4da882f6,  
 version: HTTP/1.1,  
 mediatype: None
index action called with request ()
index page's argument 
Token name csrfToken, value 0af39d7f1099e4d61e9bd05da5c50b452212ad68-1537282929407-278b8bc3fbe1c1e8aacf27d9

0 个答案:

没有答案