Middleware
It is possible to execute functions before or after the function associated with an endpoint, this in order to reprocess certain data or carry out previous validations.
function authenticate(request, HTTP)
isAuthenticated = false
if (request.params["status"] === "authenticated")
isAuthenticated = true
end
return request, HTTP, isAuthenticated
endGet("/verify/:status",
(result(;middleware=authenticate) = (request, HTTP)-> begin
myfunction = (request, HTTP, isAuthenticated)-> begin
if (isAuthenticated == false )
return HTTP.Response(403,string("Unauthenticated. Please signup!"))
end
return HTTP.Response(200,string("<b>verify !</b>"))
end
return myfunction(middleware(request,HTTP)...)
end)()
)Last updated