-
Notifications
You must be signed in to change notification settings - Fork 70
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
Showing
11 changed files
with
149 additions
and
58 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
51 changes: 51 additions & 0 deletions
51
modules/http4s/src/smithy4s/http4s/ClientEndpointMiddleware.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,51 @@ | ||
/* | ||
* Copyright 2021-2022 Disney Streaming | ||
* | ||
* Licensed under the Tomorrow Open Source Technology License, Version 1.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://disneystreaming.github.io/TOST-1.0.txt | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package smithy4s | ||
package http4s | ||
|
||
import org.http4s.client.Client | ||
|
||
// format: off | ||
trait ClientEndpointMiddleware[F[_]] { | ||
def prepare[Alg[_[_, _, _, _, _]]](service: Service[Alg])( | ||
endpoint: Endpoint[service.Operation, _, _, _, _, _] | ||
): Client[F] => Client[F] | ||
} | ||
// format: on | ||
|
||
object ClientEndpointMiddleware { | ||
|
||
trait Simple[F[_]] extends ClientEndpointMiddleware[F] { | ||
def prepareWithHints( | ||
serviceHints: Hints, | ||
endpointHints: Hints | ||
): Client[F] => Client[F] | ||
|
||
final def prepare[Alg[_[_, _, _, _, _]]](service: Service[Alg])( | ||
endpoint: Endpoint[service.Operation, _, _, _, _, _] | ||
): Client[F] => Client[F] = | ||
prepareWithHints(service.hints, endpoint.hints) | ||
} | ||
|
||
def noop[F[_]]: ClientEndpointMiddleware[F] = | ||
new ClientEndpointMiddleware[F] { | ||
override def prepare[Alg[_[_, _, _, _, _]]](service: Service[Alg])( | ||
endpoint: Endpoint[service.Operation, _, _, _, _, _] | ||
): Client[F] => Client[F] = identity | ||
} | ||
|
||
} |
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
Oops, something went wrong.