-
Notifications
You must be signed in to change notification settings - Fork 222
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
1 parent
05f6c5f
commit 34c5c94
Showing
4 changed files
with
91 additions
and
15 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package io.finch | ||
|
||
import com.twitter.finagle.Service | ||
import com.twitter.finagle.http.{Request, Response} | ||
import io.finch.internal.ToService | ||
import shapeless._ | ||
|
||
/** | ||
* Bootstraps a Finagle HTTP service out of the collection of Finch endpoints. | ||
* | ||
* {{{ | ||
* val api: Service[Request, Response] = Bootstrap | ||
* .serve[Application.Json](getUser :+: postUser) | ||
* .serve[Text.Plain](healthcheck) | ||
* .toService | ||
* }}} | ||
* | ||
* @note This API is experimental/unstable. Use with caution. | ||
*/ | ||
case class Bootstrap[ES <: HList, CTS <: HList](endpoints: ES) { self => | ||
|
||
class Serve[CT <: String] { | ||
def apply[E](e: Endpoint[E]): Bootstrap[Endpoint[E] :: ES, CT :: CTS] = | ||
self.copy(e :: self.endpoints) | ||
} | ||
|
||
def serve[CT <: String]: Serve[CT] = new Serve[CT] | ||
|
||
def toService(implicit ts: ToService[ES, CTS]): Service[Request, Response] = ts(endpoints) | ||
} | ||
|
||
object Bootstrap extends Bootstrap[HNil, HNil](HNil) |
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