-
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.
- Loading branch information
herrrta
committed
Nov 19, 2024
1 parent
ed83ff9
commit dd3a8ca
Showing
1 changed file
with
73 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,73 @@ | ||
# ktorceful | ||
[](https://repo.maven.apache.org/maven2/dev/herrrta/ktorceful/) | ||
 | ||
|
||
# Ktorceful | ||
A simple solution to easily create reusable class based routing. | ||
|
||
Avoid needing to type out repetitive routing dsl! | ||
|
||
```kotlin | ||
// Create your class based view to handle all your required HTTP methods | ||
@Resource("user") | ||
class UserRoute: Get, Post, Delete { | ||
override suspend fun get(call: RoutingCall) { | ||
// ... | ||
} | ||
|
||
override suspend fun post(call: RoutingCall) { | ||
// ... | ||
} | ||
|
||
override suspend fun delete(call: RoutingCall) { | ||
// ... | ||
} | ||
} | ||
|
||
|
||
fun Application.module() { | ||
install(Resources) | ||
// ... | ||
|
||
// Create routing using the included functions | ||
createBasicRoute<UserRoute>() | ||
} | ||
``` | ||
|
||
Any future changes to your route can all be done within your class! | ||
|
||
|
||
|
||
## Setup | ||
Add ktorceful-core dependency to your application | ||
|
||
```kotlin | ||
dependencies { | ||
implementation("dev.herrrta.ktorceful:core:x.x.x") | ||
|
||
// OPTIONAL! if using authentication in ktor | ||
implementation("dev.herrrta.ktorceful:auth:x.x.x") | ||
} | ||
``` | ||
|
||
|
||
### If you are using version catalogs: | ||
|
||
```toml | ||
[versions] | ||
ktorceful = "x.x.x" | ||
... | ||
|
||
[libraries] | ||
ktorceful-core = { module = "dev.herrrta.ktorceful:core", version.ref = "ktorceful" } | ||
|
||
# OPTIONAL! if using authentication in ktor | ||
ktorceful-auth = { module = "dev.herrrta.ktorceful:auth" } | ||
... | ||
``` | ||
|
||
```kotlin | ||
dependencies { | ||
implementation(libs.ktorceful.core) | ||
implementation(libs.ktorceful.auth) | ||
} | ||
``` |