Akka http 不支持的方法异常
Akka http unsupported method exception
我有一个像这样定义的普通 http 路由
delete {
handleErrorsAndReport("delete_foo") {
fooRepository.deleteFoo(fooId)
complete(NoContent)
}
}
我想给它添加一些基本的身份验证,所以现在它看起来像
seal(
authenticateBasic(
realm = "Secure foo",
scopeAuthenticator
) { scopes =>
delete {
handleErrorsAndReport("delete_foo") {
fooRepository.deleteFoo(fooId, scopes)
complete(NoContent)
}
}
}
)
完整的指令是
concat(
get {
// something else which is working
},
seal(
// something else which is working
),
seal(
authenticateBasic(
realm = "Secure foo",
scopeAuthenticator
) { scopes =>
delete {
handleErrorsAndReport("delete_foo") {
fooRepository.deleteFoo(fooId, scopes)
complete(NoContent)
}
}
}
)
)
现在我在尝试删除 foos 时遇到以下异常
Request DELETE http://builder/foos/fooId failed with response code 405 due to request error. Response body: HTTP method not allowed, supported methods: PUT
可能是什么问题?我使用 API 的方式没有改变,但恐怕随着 seal
指令的引入,某些事情已经改变。
我不知道为什么,但这有效
concat(
get {
// something else which is working
},
seal(
authenticateBasic(
realm = "Secure foo",
scopeAuthenticator
) { scopes =>
concat(
delete {
handleErrorsAndReport("delete_foo") {
fooRepository.deleteFoo(fooId, scopes)
complete(NoContent)
},
put {//other authenticated endpoint}
)
}
}
)
)
换句话说,我合并了之前分开的两个密封指令。可能跟this
有关
我有一个像这样定义的普通 http 路由
delete {
handleErrorsAndReport("delete_foo") {
fooRepository.deleteFoo(fooId)
complete(NoContent)
}
}
我想给它添加一些基本的身份验证,所以现在它看起来像
seal(
authenticateBasic(
realm = "Secure foo",
scopeAuthenticator
) { scopes =>
delete {
handleErrorsAndReport("delete_foo") {
fooRepository.deleteFoo(fooId, scopes)
complete(NoContent)
}
}
}
)
完整的指令是
concat(
get {
// something else which is working
},
seal(
// something else which is working
),
seal(
authenticateBasic(
realm = "Secure foo",
scopeAuthenticator
) { scopes =>
delete {
handleErrorsAndReport("delete_foo") {
fooRepository.deleteFoo(fooId, scopes)
complete(NoContent)
}
}
}
)
)
现在我在尝试删除 foos 时遇到以下异常
Request DELETE http://builder/foos/fooId failed with response code 405 due to request error. Response body: HTTP method not allowed, supported methods: PUT
可能是什么问题?我使用 API 的方式没有改变,但恐怕随着 seal
指令的引入,某些事情已经改变。
我不知道为什么,但这有效
concat(
get {
// something else which is working
},
seal(
authenticateBasic(
realm = "Secure foo",
scopeAuthenticator
) { scopes =>
concat(
delete {
handleErrorsAndReport("delete_foo") {
fooRepository.deleteFoo(fooId, scopes)
complete(NoContent)
},
put {//other authenticated endpoint}
)
}
}
)
)
换句话说,我合并了之前分开的两个密封指令。可能跟this
有关