Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@mikem
Copy link
Contributor

@mikem mikem commented Sep 3, 2016

I found the Default controller useful and thought it'd be good to mention it in the routing documentation. This PR does that, along with some other minor documentation fixes.

@mikem
Copy link
Contributor Author

mikem commented Sep 3, 2016

Oh, looks like the docs are compiled, too. I took a look, but I'm running out of time to dig into how to set this straight. Any pointers welcome :-)

@wsargent
Copy link
Member

wsargent commented Sep 3, 2016

You need to specify the full path to the controller type in routes:

[error] /home/travis/build/playframework/playframework/documentation/manual/working/javaGuide/main/http/code/javaguide.http.routing.defaultcontroller.routes:3: type Default is not a member of package javaguide.http.routing.defaultcontroller.controllers
[error] GET   /about      controllers.Default.redirect(to = "https://www.playframework.com/")
[error] 

https://travis-ci.org/playframework/playframework/builds/157275557#L3208

@mikem
Copy link
Contributor Author

mikem commented Sep 4, 2016

@wsargent hm, but I'd rather the code samples in the documentation show exactly how one would use the Default controller in their own project.

I managed to get the build passing in c47c406. There are a couple of things I'd like to improve, but can't figure out how. See my comments below.

import play.api.mvc.Controller
import _root_.controllers.{Default => PlayDefault}

class Default extends Controller {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It'd be great not to have to declare a new controller myself here, and just import the Default controller and be done with it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mikem Why not just

class Default extends _root_.controllers.Default

?

It's somewhat annoying that we have to do this. I never really liked the fact that we have stuff in a top-level controllers package either (I would rather it be play.controllers or something).

Also:

- correct the return code in the `Default` controller's `redirect`
  action Scaladoc
- fix ScalaSirdRouter link
Also, tests for routing to Default controller.
@mikem mikem force-pushed the document-default-controller branch from c47c406 to 2614316 Compare September 12, 2016 07:10
@mikem
Copy link
Contributor Author

mikem commented Sep 12, 2016

@gmethvin thanks for the suggestion -- I applied it in 2614316.

I also rebased my branch on top of the current master.

@gmethvin gmethvin merged commit 6f7dc7a into playframework:master Sep 12, 2016
gmethvin pushed a commit that referenced this pull request Sep 12, 2016
* Document Default controller in routing docs

Also:

- correct the return code in the `Default` controller's `redirect`
  action Scaladoc
- fix ScalaSirdRouter link

* Documentation compiles again

Also, tests for routing to Default controller.

* Simplify Default controllers
@mikem mikem deleted the document-default-controller branch September 12, 2016 14:02
@mkurz mkurz added this to the 2.5.7 milestone Sep 13, 2016
wsargent pushed a commit to wsargent/playframework that referenced this pull request Oct 25, 2016
* Document Default controller in routing docs

Also:

- correct the return code in the `Default` controller's `redirect`
  action Scaladoc
- fix ScalaSirdRouter link

* Documentation compiles again

Also, tests for routing to Default controller.

* Simplify Default controllers
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants