Closed xiusin closed 3 years ago
I didn't know they have the same memory address for this. But if that's your concern, what are the implication for this?
i write a middleware cors.v
the code as follows:
pub fn cors(mut req ctx.Req, mut res ctx.Resp) {
res.headers["Access-Control-Allow-Origin"] = ["http://localhost:3100"]
res.headers["Access-Control-Allow-Methods"] = ["POST"]
res.headers["Access-Control-Allow-Headers"] = ["x-requested-with, content-type"]
println(res.headers) // here
}
but only first request print info :
{'Content-Type': ['text/html; charset=UTF-8'], 'X-Powered-By': ['VEX/0.3.5'], 'Server': ['VEX'], 'Access-Control-Allow-Origin': ['http://localhost:3100'], 'Access-Control-Allow-Methods': ['POST'], 'Access-Control-Allow-Headers': ['x-requested-with, content-type']}
Other requests print info:
{'Content-Type': ['text/html; charset=UTF-8'], 'X-Powered-By': ['VEX/0.3.5'], 'Server': ['VEX']}
So, only the first request is effective.
Hi @xiusin, i have same case, how you handle for this case?
@ZihxS I suggest using vweb
, which seems to be no longer maintained.
I also wrote a simple framework, you can try it if you are interested.
https://github.com/nedpals/vex/blob/master/router/router.v#L44
print :