carousell/Orion

Custom HTTP handlers should not be limited to OPTIONS method

Closed this issue · 0 comments

Currently the ability to register a HTTP interceptor is only available if the OPTIONS method is declared on the endpoint.

It should either be available always, or as long as any method is defined using ORION:URL:

One use-case for the HTTP interceptor is when using websockets, access to http.ResponseWriter and http.Request is needed to upgrade the connection.

if strings.ToLower(methods[i]) == "options" {
optionsEncoder = true
}

if optionsEncoder {
P(g, "")
P(g, "func Register", svc.GetName(), method.GetName(), "Handler(svr orion.Server, handler orion.HTTPHandler) {")
P(g, "\torion.RegisterHandler(svr, \""+svc.GetName()+"\", \""+method.GetName()+"\", \""+option.Path+"\", handler)")
P(g, "}")
}