anz-bank / pkg

Common ANZ Go packages
https://pkg.go.dev/github.com/anz-bank/pkg
Apache License 2.0
1 stars 9 forks source link

health: Add HTTPServer.RegisterWith method #53

Closed camscale closed 4 years ago

camscale commented 4 years ago

Add the RegisterWith method to HTTPServer to register all three health paths with a mux. The mux needs to implement the health.Router interface which http.ServeMuxdoes . chi also does, for example. Unfortunately gorilla/mux does not (it has a return value).

Reimplement ServeHTTP in with RegisterWith on a http.ServeMux to remove the code duplication that would have otherwise existed.

Adjust the TestHTTPMethodNotAllowed test as the order of checking paths and methods have changed.

Also rename TestRegisterWith to TestGRPCRegisterWith since there is now another RegisterWith.