-
Notifications
You must be signed in to change notification settings - Fork 138
Add MyRequest #118
base: master
Are you sure you want to change the base?
Add MyRequest #118
Conversation
ce7d651
to
bd78888
Compare
@akkie I think this is a good practice because people will want to customize the request, also see the XXX bits for where traits would be used. |
@wsargent What's the advantage over using the action refiner? For me it looks like a lot of boilerplate. Could you assemble a really small example that can then be used in the documentation? |
I did some refactoring and switched to ActionTransformer. Does this work? abstract class SomeAbstractController @Inject() (controllerComponents: SilhouetteControllerComponents) {
type SecuredEnvRequest[A] = SecuredRequest[DefaultEnv, A]
protected abstract class AbstractActionTransformer[-R[_], +P[_]](cc: SilhouetteControllerComponents) extends ActionTransformer[R, P] {
override protected def executionContext: ExecutionContext =
cc.executionContext
}
class MySecuredActionTransformer(cc: SilhouetteControllerComponents) extends AbstractActionTransformer[SecuredEnvRequest, MySecuredRequest](cc) {
override protected def transform[A](request: SecuredEnvRequest[A]): Future[MySecuredRequest[A]] = {
Future.successful( new MySecuredRequest[A](
messagesApi = cc.messagesApi,
identity = request.identity,
authenticator = request.authenticator,
request = request
))
}
}
private val mySecuredActionTransformer = new MySecuredActionTransformer(controllerComponents)
def SecuredAction: ActionBuilder[MySecuredRequest, AnyContent] = {
controllerComponents.silhouette.SecuredAction.andThen(mySecuredActionTransformer)
}
} |
bd78888
to
cef7458
Compare
07e4d94
to
2a25d60
Compare
Probably should split up into |
Okay, broken out some more. |
69137ee
to
3b1633f
Compare
@wsargent Thanks 👍 It looks much cleaner and more understandable now. I've some notes to your implementation. Some are global some I will comment inline.
|
@akkie updated with comment fixes |
The type alias can be used by subclasses. The parametrized type can’t.
…On Thu, Jan 16, 2020 at 11:07 PM Christian Kaps ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In app/controllers/SilhouetteController.scala
<#118 (comment)>
:
> def eventBus: EventBus = silhouette.env.eventBus
}
-trait SilhouetteComponents {
+trait SilhouetteComponents[E <: Env] {
+ type EnvType = E
Why not using E directly?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#118?email_source=notifications&email_token=AMUFROUVASV55WUOGKOWEUTQ6FKMXA5CNFSM4KBHG472YY3PNVWWK3TUL52HS4DFWFIHK3DMKJSXC5LFON2FEZLWNFSXPKTDN5WW2ZLOORPWSZGOCSDQWQY#pullrequestreview-344394563>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AMUFROREMCSSXFB35AOMKVLQ6FKMXANCNFSM4KBHG47Q>
.
|
@akkie how does it look? |
I thought we should wait for the next Silhouette release, so that you can depend on mohiva/play-silhouette#574. But the next Silhouette release depends on the new Play 2.8.1 release because of mohiva/play-silhouette#570 |
I’m fine with rebasing and merging any conflicts
…On Sun, Jan 26, 2020 at 11:15 PM Christian Kaps ***@***.***> wrote:
I thought we should wait for the next Silhouette release, so that you can
depend on mohiva/play-silhouette#574
<mohiva/play-silhouette#574>. But the next
Silhouette release depends on the new Play 2.8.1 release because of
mohiva/play-silhouette#570
<mohiva/play-silhouette#570>
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#118?email_source=notifications&email_token=AMUFROR6OU6OCOT5Q4RKFC3Q72CY7A5CNFSM4KBHG472YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEJ6QQLI#issuecomment-578619437>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AMUFROXHMED6RARB6RMRZX3Q72CY7ANCNFSM4KBHG47Q>
.
|
@akkie 2.8.1 is out now https://github.com/playframework/playframework/releases/tag/2.8.1 |
@wsargent I've released the final 7.0.0 |
This is a sample PR to show extending a custom request type on top of SecuredRequest.
Note that since MyRequest extends MessagesRequest it is automatically a
MessagesProvider
so that's one fewer implicit to pass around