go-sdk
go-sdk copied to clipboard
Added Server.Unwrap function
This is a tiny commit, mostly for internal use.
I did it to support adding middlewares (such as logging, which is my case) over the http.ServeMux generated by the Dapr SDK.
It is probably not the cleanest way to do that though, as you still need to cast the daprd.NewServiceWithMux()
output with s.(*daprd.Server)
@skyao please review this
// Gets the underlying serve address and http.ServeMux
func (s *Server) Unwrap() (string, *http.ServeMux) {
return s.address, s.mux
}
This function exposures the underlying implementation details, it is realy NOT a clean way as you say. It breaks the design, can we find a better way?
I don't know, for this specific case it would be a good idea to implement adding middlewares on top of the internal handler, while not exposing the values like i did in my commit.
Or it should be possible to start treating the returned values as public, while also making sure that you cannot use the Server
structure anymore (because messing with these values WILL break it).
@skyao what do you think?
@skyao what do you think?
I have given my comments: I understand the requirement from , but I think we need find a better way, which won't break the design.