-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: Introduce tapir on Pekko (#2870)
Co-authored-by: Marcin Procyk <[email protected]>
- Loading branch information
Showing
15 changed files
with
455 additions
and
150 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
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
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
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
35 changes: 35 additions & 0 deletions
35
webapi/src/main/scala/org/knora/webapi/routing/BaseEndpoints.scala
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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
* Copyright © 2021 - 2023 Swiss National Data and Service Center for the Humanities and/or DaSCH Service Platform contributors. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.knora.webapi.routing | ||
|
||
import sttp.model.StatusCode | ||
import sttp.tapir.EndpointOutput | ||
import sttp.tapir.endpoint | ||
import sttp.tapir.generic.auto._ | ||
import sttp.tapir.json.zio.jsonBody | ||
import sttp.tapir.oneOf | ||
import sttp.tapir.oneOfVariant | ||
import sttp.tapir.statusCode | ||
import zio.ZLayer | ||
|
||
import dsp.errors.BadRequestException | ||
import dsp.errors.NotFoundException | ||
import dsp.errors.RequestRejectedException | ||
|
||
final case class BaseEndpoints() { | ||
|
||
private val defaultErrorOutputs: EndpointOutput.OneOf[RequestRejectedException, RequestRejectedException] = | ||
oneOf[RequestRejectedException]( | ||
oneOfVariant[NotFoundException](statusCode(StatusCode.NotFound).and(jsonBody[NotFoundException])), | ||
oneOfVariant[BadRequestException](statusCode(StatusCode.BadRequest).and(jsonBody[BadRequestException])) | ||
) | ||
|
||
val publicEndpoint = endpoint.errorOut(defaultErrorOutputs) | ||
} | ||
|
||
object BaseEndpoints { | ||
val layer = ZLayer.derive[BaseEndpoints] | ||
} |
Oops, something went wrong.