request. If they are, it retrieves some information about the user that
I've stored. If they're not logged in, I need to redirect the user to the
I cannot figure out a DRY way to do this. Currently, every request handler
tries to bootstrap the user object, and sets the redirect header and
returns early if the user isn't logged in. I can't help but feel there must
be a less redundant way to handle this than copy/pasting that logic into
every. single. request handler. I've tried e.g., passing the request and
response objects to the user bootstrap function to set the header there,
but I still have to trigger the user object bootstrap process, and check
for an error in the request handler and return early. Ideally, the
logged-in check would happen in only one place, and that place would also
pass the user object into the request handler.
Is there a better way to handle this?
I'm using the Gorilla mux library, but I'm open to others if they can solve
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to email@example.com.
For more options, visit https://groups.google.com/groups/opt_out.