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

Skip to content

jilen/play-zlayer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

play-zlayer

Intro

A play! framework app managed by ZLayer

How ?

Play compile routes file into a class like

class Routes(
  httpErrorHandler: HttpErrorHandler,
  xxxControler0: XXXController0,
  xxxControler1: XXXController1,
  ...
)

Assume there are layer

val controllerLayers = ZLayer[R, XXX, Has[BuiltInComponents] with  Has[XXXControler0] with Has[XXXControler1] ...]

It could be easily map to Routes above

val routesLayer = controllerLayers.map { env =>
  val _routes = Routes(
    env.get[BuiltInComponents].httpErrorHandler,
    env.get[XXXControler0],
    env.get[XXXControler1],
    ...
  )
  Has(_routes)
}

And then we can simply run the layer get the Routes and feed it to custom ApplicationLoader which is intended for compile-tim di.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages