-
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
c64c966
commit 5fc4c74
Showing
3 changed files
with
89 additions
and
11 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,33 @@ | ||
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 it with caution. | ||
*/ | ||
case class Bootstrap[ES <: HList, CTS <: HList](es: ES) { self => | ||
|
||
class Serve[CT <: String] { | ||
def apply[E](e: Endpoint[E]): Bootstrap[Endpoint[E] :: ES, CT :: CTS] = | ||
self.copy(e :: self.es) | ||
} | ||
|
||
def serve[CT <: String]: Serve[CT] = new Serve[CT] | ||
|
||
def toService(implicit ts: ToService[ES, CTS]): Service[Request, Response] = ts(es) | ||
} | ||
|
||
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