Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Server.Unwrap function #162

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

Conversation

handicraftsman
Copy link

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)

@yaron2
Copy link
Member

yaron2 commented May 4, 2021

@skyao please review this

@yaron2 yaron2 requested a review from skyao May 4, 2021 16:04
@skyao skyao self-assigned this May 7, 2021
@skyao
Copy link
Member

skyao commented May 7, 2021

// 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?

@handicraftsman
Copy link
Author

handicraftsman commented May 7, 2021

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).

@yaron2
Copy link
Member

yaron2 commented May 24, 2021

@skyao what do you think?

@skyao
Copy link
Member

skyao commented May 25, 2021

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants