gpt4 book ai didi

scala - Play Framework 2.1 : Scala: how to get the whole base url (including protocol)?

转载 作者:行者123 更新时间:2023-12-03 23:24:40 28 4
gpt4 key购买 nike

目前我可以从 request 获取主机。 ,其中包括域和可选端口。不幸的是,它不包含协议(protocol)(http 与 https),因此我无法为站点本身创建绝对 url。

object Application extends Controller {
def index = Action { request =>
Ok(request.host + "/some/path") // Returns "localhost:9000/some/path"
}
}

有没有办法从请求对象中获取协议(protocol)?

最佳答案

在 Play 2.3 及更高版本中,您可以使用 the secure property of the Request类(class)。

关于scala - Play Framework 2.1 : Scala: how to get the whole base url (including protocol)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14863553/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com