-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(core): cleanup layer logic some more
- Loading branch information
1 parent
941334f
commit 9077427
Showing
5 changed files
with
16 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,6 @@ | ||
package sh.illumi.kraft.layer | ||
|
||
import kotlinx.coroutines.CoroutineScope | ||
import sh.illumi.kraft.service.ServiceContainer | ||
|
||
/** | ||
* The root layer in the application layer stack | ||
* | ||
* @property depth The depth of this layer in the tree. Defaults to [ApplicationLayer.ROOT_DEPTH] | ||
*/ | ||
abstract class RootLayer( | ||
override val coroutineScope: CoroutineScope, | ||
) : ApplicationLayer { | ||
override val depth: Int = ApplicationLayer.ROOT_DEPTH | ||
|
||
@Suppress("LeakingThis") | ||
override val services = ServiceContainer(this) | ||
|
||
init { | ||
@Suppress("LeakingThis") | ||
instance = this | ||
} | ||
|
||
abstract suspend fun start() | ||
|
||
companion object { | ||
lateinit var instance: RootLayer | ||
} | ||
} | ||
interface RootLayer : ApplicationLayer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 1 addition & 7 deletions
8
kraftx/http/src/main/kotlin/sh/illumi/kraft/x/http/extensions/routing.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1 @@ | ||
package sh.illumi.kraft.x.http.extensions | ||
|
||
import io.ktor.server.routing.* | ||
import sh.illumi.kraft.layer.RootLayer | ||
import sh.illumi.kraft.service.ServiceContainer | ||
|
||
val RoutingContext.services: ServiceContainer get() = RootLayer.instance.services | ||
package sh.illumi.kraft.x.http.extensions |