go-json-rest icon indicating copy to clipboard operation
go-json-rest copied to clipboard

How to convert http.HandlerFunc to rest.HandlerFunc

Open Telmo opened this issue 9 years ago • 2 comments

I am trying to create a prometheus middleware for go-json-rest and I am running into issues due to the differences between the rest.ResponseWriter and the http.ResponseWriter

I am able to get the http.HandlerFunc for prometheus but when trying to get it into a rest.Get I am unable to convert the http.HandlerFunc into a rest.HandlerFunc as far as I can tell the only difference between them is the ResponseWriter

https://godoc.org/net/http#ResponseWriter https://godoc.org/github.com/ant0ine/go-json-rest/rest#ResponseWriter

Is there a way to accomplish this? I am fairly new to go so if the answer is pretty obvious I apologize in advance :)

Telmo avatar Jul 20 '16 13:07 Telmo

Agreed. There should be methods to switch from http.Request to rest.Request. Same for ResponseWriter

ajpen avatar Sep 01 '16 15:09 ajpen

@Telmo You mind checking if that PR fixes the issue?

ajpen avatar Sep 29 '16 19:09 ajpen