-
Notifications
You must be signed in to change notification settings - Fork 411
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into optimise_streamDecoder
- Loading branch information
Showing
12 changed files
with
610 additions
and
8 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 |
---|---|---|
@@ -0,0 +1,36 @@ | ||
--- | ||
id: endpoint-scala3 | ||
title: "Endpoint Scala 3 Syntax" | ||
sidebar_label: "Endpoint Scala 3 Syntax" | ||
--- | ||
|
||
```scala | ||
import zio.http.* | ||
import zio.http.codec.* | ||
import zio.http.endpoint.* | ||
|
||
import java.util.UUID | ||
|
||
type NotFound[EntityId] = EntityId | ||
type EntityId = UUID | ||
|
||
val union: ContentCodec[String | UUID | Boolean] = | ||
HttpCodec.content[String] || HttpCodec.content[UUID] || HttpCodec.content[Boolean] | ||
|
||
val unionEndpoint = | ||
Endpoint(Method.GET / "api" / "complex-union") | ||
.outCodec(union) | ||
|
||
val unionWithErrorEndpoint | ||
: Endpoint[Unit, Unit, NotFound[EntityId] | String, UUID | Unit, AuthType.None] = | ||
Endpoint(Method.GET / "api" / "union-with-error") | ||
.out[UUID] | ||
.orOut[Unit](Status.NoContent) | ||
.outError[NotFound[EntityId]](Status.NotFound) | ||
.orOutError[String](Status.BadRequest) | ||
|
||
val impl = unionWithErrorEndpoint.implementEither { _ => | ||
val result: Either[NotFound[EntityId] | String, UUID | Unit] = Left("error") | ||
result | ||
} | ||
``` |
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
Oops, something went wrong.
a81e7ba
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀 : Performance Benchmarks (SimpleEffectBenchmarkServer)
concurrency: 256
requests/sec: 370592
a81e7ba
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀 : Performance Benchmarks (PlainTextBenchmarkServer)
concurrency: 256
requests/sec: 353270