Skip to content

Commit

Permalink
(doc): add notes about previous repositories
Browse files Browse the repository at this point in the history
  • Loading branch information
LukasForst committed Aug 9, 2022
1 parent 91ebe9b commit b9696c6
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 4 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

![GitHub release (latest SemVer)](https://img.shields.io/github/v/release/LukasForst/ktor-plugins?style=flat-square)

Collection of useful Ktor plugins. All plugins are hosted on Maven central and can be added to your project as easy as:
Collection of useful Ktor plugins. All plugins are hosted on Maven central and have same version that should be similar
to the latest version of Ktor. The plugins can be added to your project as easy as:

```kotlin
implementation("dev.forst", "ktor-<plugin>", "<latest version>")
Expand Down
3 changes: 2 additions & 1 deletion ktor-api-key/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
![GitHub release (latest SemVer)](https://img.shields.io/github/v/release/LukasForst/ktor-plugins?style=flat-square)

Simple authentication provider for Ktor that verifies presence of the API key in the header. Useful if you want to
use `X-Api-Key` or similar approaches for request authentication.
use `X-Api-Key` or similar approaches for request authentication. Originally hosted
in [LukasForst/ktor-api-key](https://github.com/LukasForst/ktor-api-key) repository.

## Installation

Expand Down
50 changes: 49 additions & 1 deletion ktor-openapi-generator/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,51 @@
# Ktor OpenAPI Generator

Hosted on different repository: https://github.com/LukasForst/ktor-openapi-generator/
Hosted on different
repository: [LukasForst/ktor-openapi-generator](https://github.com/LukasForst/ktor-openapi-generator/).

## Minimal example

```kotlin
/**
* Minimal example of OpenAPI plugin for Ktor.
*/
fun Application.minimalExample() {
// install OpenAPI plugin
install(OpenAPIGen) {
// this automatically servers Swagger UI on /swagger-ui
serveSwaggerUi = true
info {
title = "Minimal Example API"
}
}
// install JSON support
install(ContentNegotiation) {
jackson()
}
// add basic routes for openapi.json and redirect to UI
routing {
// serve openapi.json
get("/openapi.json") {
call.respond(this@routing.application.openAPIGen.api.serialize())
}
// and do redirect to make it easier to remember
get("/swagger-ui") {
call.respondRedirect("/swagger-ui/index.html?url=/openapi.json", true)
}
}
// and now example routing
apiRouting {
route("/example/{name}") {
// SomeParams are parameters (query or path), SomeResponse is what the backend returns and SomeRequest
// is what was passed in the body of the request
post<SomeParams, SomeResponse, SomeRequest> { params, someRequest ->
respond(SomeResponse(bar = "Hello ${params.name}! From body: ${someRequest.foo}."))
}
}
}
}

data class SomeParams(@PathParam("who to say hello") val name: String)
data class SomeRequest(val foo: String)
data class SomeResponse(val bar: String)
```
3 changes: 2 additions & 1 deletion ktor-rate-limiting/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

![GitHub release (latest SemVer)](https://img.shields.io/github/v/release/LukasForst/ktor-plugins?style=flat-square)

A simple library that enables Rate Limiting in Ktor.
A simple library that enables Rate Limiting in Ktor. Originally
hosted in [LukasForst/ktor-rate-limiting](https://github.com/LukasForst/ktor-rate-limiting) repository.

## Installation

Expand Down

0 comments on commit b9696c6

Please sign in to comment.