How to handle Options Method?
frizkyzendy opened this issue · 2 comments
How to Handle 2 method options to same view function ?
I must pair PUT with OPTIONS method but also must pair DELETE with OPTIONS method.
If I do that, there a clash with OPTIONS method because they refered different functions.
example code :
e.Path("GET", "/prospect", handler.Fetch)
e.Path("POST", "/prospect", handler.Store)
e.Path("PUT", "/prospect/:key", handler.Update)
e.Path("OPTIONS", "/prospect/:key", handler.Update)
e.Path("DELETE", "/prospect/:key", handler.Delete)
e.Path("OPTIONS", "/prospect/:key", handler.Delete)
How to resolve that ?
Hi @Zend87,
The OPTIONS handle is activated for all registered Paths
by default, but if you need it just for an specific paths, you must disable it with HandleOPTIONS and adds an extra path for each path that you need to handle:
e.Path("OPTIONS", "<Path to handle options>", func(ctx *atreugo.RequestCtx) error {
return ctx.TextResponse("OK")
})
Sorry for delayed answer!