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

Middleware support? #406

Open
tadasv opened this issue Jun 11, 2023 · 1 comment
Open

Middleware support? #406

tadasv opened this issue Jun 11, 2023 · 1 comment

Comments

@tadasv
Copy link

tadasv commented Jun 11, 2023

I was trying to find find documentation of how to add custom middlewares? An example would be an auth middleware that checks whether user is logged in or not. How would you achieve that with bud?

@matthewmueller
Copy link
Contributor

matthewmueller commented Jul 16, 2023

Hey @tadasv this will becoming a future release. For now, you can add a function at the top of your controller actions to do these sorts of checks.

Something like:

package users

type Controller {
  // Deps
}

func (c *Controller) Create(w http.ResponseWriter, r *http.Request) {
  if !users.Authenticated(w, r) {
    return http.Error(w, "forbidden", 400)
  } 
}

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

No branches or pull requests

2 participants