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

Reusing brokerapi middlewares #83

Closed
desislavaa opened this issue Sep 27, 2019 · 3 comments
Closed

Reusing brokerapi middlewares #83

desislavaa opened this issue Sep 27, 2019 · 3 comments
Labels

Comments

@desislavaa
Copy link
Contributor

I am working on a service broker that is supposed to do audit logging. In order for us to achieve that we need to use custom authentication middleware and later AttachRoutes to our router.

Since adding reusable code in pkg folder is commonly used but not considered a standard in Go, my question is, can we attach the brokerapi middlewares instead of implementing our own? Is this functionality supposed to be reused?

@cf-gitbot
Copy link
Member

We have created an issue in Pivotal Tracker to manage this:

https://www.pivotaltracker.com/story/show/168801074

The labels on this github issue will be updated when the story is started.

@kirederik
Copy link
Contributor

Hi @desislavaa,

Just to guarantee that we understand your question:

You want to implement a custom auth middleware and reuse all the other broker middlewares (as defined here). That means that in your code you would have a function similar to brokerapi.New, just changing the auth middleware to your custom implementation. Your question is whether or not this is a good idea/recommended?

If so, yes. Feel free to reuse the broker middlewares. That's actually why we have AttachRoutes as a public method.

We would also be curious to hear if you have any ideas on how to make it easier for users of the brokerapi to provide custom middlewares.

Let us know if you need further help.

Thanks!

@desislavaa
Copy link
Contributor Author

That was exactly my question, thank you for the quick response!

We thought about a wrapper function of New, let's say NewWithAuthorizer, where the user can pass an implementation of an Authorizer interface or something like that, but that would work only for our particular use case (however, if you like the idea, we'll be glad to contribute it).

If we pass user-provided middlewares instead, a problem would be their order, so the already present approach with adding them manually looks more suitable.
Adding them at the end is also possible at the moment, since New returns a router.
If we think of anything that could possibly solve that, we'll be happy to share it.

Thanks again!

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

No branches or pull requests

3 participants