【发布时间】:2020-06-16 10:37:03
【问题描述】:
当路由方法(HTTP 动词)不匹配时如何发送自定义响应?
当我在 post 方法中点击以下路线时
r.handleFunc("/destination", handler).Methods('GET')
我想接收(假设它是 JSON 响应)
{
status: "ERROR",
message: "Route method not supported."
}
我的想法是我不想让每个处理程序都带有 route.Method == $METHOD 检查。寻找一种我可以定义一次并应用于每条路线的方法。
【问题讨论】: