Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable http in finatra app

I am deploying a Finatra app to Heroku. Thanks to Twitter guys together with Heroku this is a very easy task. The thing is that Heorku gives you https out of the box (if im trying to reach my service through https it just works). Nevertheless it also works with http requests. Is there any way to disable http requests and leave only https?

Thanks

like image 370
Gal Avatar asked Feb 19 '26 06:02

Gal


1 Answers

You can disable the http request by override the defaultHttpPort value to an empty String (and do not pass a value for the -http.port flag)

import com.twitter.finagle.Http
import com.twitter.finatra.http.HttpServer
import com.twitter.finatra.http.routing.HttpRouter

object ExampleHttpsServerMain extends ExampleHttpsServer

class ExampleHttpsServer
  extends HttpServer
  with Tls {

  override val defaultHttpPort: String = "" // disable the default HTTP port
  override val defaultHttpsPort: String = ":443"

  override def configureHttp(router: HttpRouter): Unit = {
    router
      .add[ExampleController]
  }
}

Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!