I’m creating a middleware and I’m wondering if I could make
call
available from it ? :
Copy code
fun Application.hasSignedUrlMiddleware() {
routing {
val uri = call.request.uri
// if(url doesn't have a signed url) {
// throw AuthorizationException("Sorry you are not authorized")
// }
}
}
Copy code
get("/posts") {
hasSignedUrlMiddleware()
call.respond(mapOf("posts" to postDAO.all()))
}
a
Aleksei Tirman [JB]
02/24/2022, 9:07 AM
It doesn't look like middleware. Could you please describe your problem?
d
dany giguere
02/24/2022, 12:43 PM
basically I want something (I call them middlewares) to perform some actions ASAP when a request enters a route (maybe restrict access to a route). But I’d need to be able to access the
call
object (the request) from it . Because I need to get the inputs/parameters from the request to build my logic.