2016-05-30 7 views
1

Mit Akka http, wie kann ich jede Anfrage auf http zu https umleiten und, falls erforderlich, die vollständige Domain zum Host-Namen hinzufügen?Akka http Redirect Anfrage an https mit FQDN

Ich war auf der Suche auf der Directives.redirect Funktion, aber es scheint Protokoll nicht bewusst zu sein ...

[Bearbeiten]: Typo in Titel, "Akke" -> "Akka".

Antwort

2

Für die Zukunft, benutzte ich Http().bindAndHandle und konstruiert, um die Route wie folgt:

lazy val httpsRedirectRoute: Route = extractUri(redirectHttps) 

def redirectHttps(uri: Uri): Route = redirect(toHttps(uri), StatusCodes.PermanentRedirect) 

def toHttps(uri: Uri): Uri = uri.copy(scheme = "https")