5

Struts アプリケーションでは、リダイレクトを介して特定のページに https 経由でのみアクセスすることを強制するフィルターがあります。私はそれをリフトに移植することを考えているので、私の質問は次のとおりです:この環境では、そのようなフィルターを実装する「リフト」方法はありますか、それともストラットと同様/同じですか? ありがとう

4

1 に答える 1

11

リフトでは、サイトマップはページアクセスのルールを定義します。特定のページでhttpsサイトにリダイレクトするSiteMapエントリを作成できます。

// create an object that does a redirect to the https server if the
// request is on http
object RequireSSL extends Loc.EarlyResponse(
  () => {
    for {
      r <- S.request
      lowLevelReq <- Box !! r if lowLevelReq.scheme == "http"
    } {
      S.redirectTo("https://"+lowLevelReq.serverName+lowLevelReq.contextPath)
    }
    Empty
  })

// Build SiteMap
def entries = (Menu("Home") / "index") ::
(Menu("Secure") / "secure" >> RequireSSL) ::
Nil

お役に立てれば。

于 2010-06-28T22:09:15.383 に答える