Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move reusable API parts to a trait #1614

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions eclair-node/src/main/scala/fr/acinq/eclair/Boot.scala
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import java.io.File

import akka.actor.ActorSystem
import akka.http.scaladsl.Http
import akka.stream.{ActorMaterializer, BindFailedException}
import akka.stream.BindFailedException
import fr.acinq.eclair.api.Service
import grizzled.slf4j.Logging
import kamon.Kamon
Expand Down Expand Up @@ -69,18 +69,16 @@ object Boot extends App with Logging {
val config = system.settings.config.getConfig("eclair")
if (config.getBoolean("api.enabled")) {
logger.info(s"json API enabled on port=${config.getInt("api.port")}")
implicit val materializer = ActorMaterializer()
val apiPassword = config.getString("api.password") match {
case "" => throw EmptyAPIPasswordException
case valid => valid
}
val apiRoute = new Service {
override val actorSystem = system
override val mat = materializer
override val password = apiPassword
override val eclairApi: Eclair = new EclairImpl(kit)
}.route
Http().bindAndHandle(apiRoute, config.getString("api.binding-ip"), config.getInt("api.port")).recover {
}.finalRoute
Http().newServerAt(config.getString("api.binding-ip"), config.getInt("api.port")).bindFlow(apiRoute).recover {
case _: BindFailedException => onError(TCPBindException(config.getInt("api.port")))
}
} else {
Expand Down
Loading