This project was created using the Ktor Project Generator.
Here are some useful links to get you started:
- Ktor Documentation
- Ktor GitHub page
- The Ktor Slack chat. You'll need to request an invite to join.
Here's a list of features included in this project:
Name | Description |
---|---|
Raw Sockets | Adds raw socket support for TCP and UDP |
Raw Secure SSL/TLS Sockets | Adds secure socket support for TCP and UDP |
Task Scheduling | Manages scheduled tasks across instances of your distributed Ktor server |
Rate Limiting | Manage request rate limiting as you see fit |
Routing | Provides a structured routing DSL |
WebSockets | Adds WebSocket protocol support for bidirectional client connections |
Koin | Provides dependency injection |
kotlinx.serialization | Handles JSON serialization using kotlinx.serialization library |
Content Negotiation | Provides automatic content conversion according to Content-Type and Accept headers |
Postgres | Adds Postgres database to your application |
Kafka | Adds Kafka support to your application |
Jackson | Handles JSON serialization using Jackson library |
GSON | Handles JSON serialization using GSON library |
Micrometer Metrics | Enables Micrometer metrics in your Ktor server application. |
Metrics | Adds supports for monitoring several metrics |
Call Logging | Logs client requests |
Swagger | Serves Swagger UI for your project |
Simple Cache | Provides API for cache management |
Simple Redis Cache | Provides Redis cache for Simple Cache plugin |
OpenAPI | Serves OpenAPI documentation |
HttpsRedirect | Redirects insecure HTTP requests to the respective HTTPS endpoint |
Forwarded Headers | Allows handling proxied headers (X-Forwarded-*) |
Default Headers | Adds a default set of headers to HTTP responses |
CORS | Enables Cross-Origin Resource Sharing (CORS) |
Conditional Headers | Skips response body, depending on ETag and LastModified headers |
Compression | Compresses responses using encoding algorithms like GZIP |
Caching Headers | Provides options for responding with standard cache-control headers |
Status Pages | Provides exception handling for routes |
Static Content | Serves static files from defined locations |
Resources | Provides type-safe routing |
Request Validation | Adds validation for incoming requests |
DoubleReceive | Allows ApplicationCall.receive several times |
AutoHeadResponse | Provides automatic responses for HEAD requests |
Sessions | Adds support for persistent sessions through cookies or headers |
Authentication | Provides extension point for handling the Authorization header |
Authentication OAuth | Handles OAuth Bearer authentication scheme |
CSRF | Cross-site request forgery mitigation |
Authentication JWT | Handles JSON Web Token (JWT) bearer authentication scheme |
Authentication Basic | Handles 'Basic' username / password authentication scheme |
To build or run the project, use one of the following tasks:
Task | Description |
---|---|
./gradlew test |
Run the tests |
./gradlew build |
Build everything |
buildFatJar |
Build an executable JAR of the server with all dependencies included |
buildImage |
Build the docker image to use with the fat JAR |
publishImageToLocalRegistry |
Publish the docker image locally |
run |
Run the server |
runDocker |
Run using the local docker image |
If the server starts successfully, you'll see the following output:
2024-12-04 14:32:45.584 [main] INFO Application - Application started in 0.303 seconds.
2024-12-04 14:32:45.682 [main] INFO Application - Responding at http://0.0.0.0:8080