So as I said in previous posts I am new to golang. I am building an educational project to learn with but also trying to build something I will eventually have production use.
My application is a golang RESTful backend and an Angular JS front end. I am new to Angular as well if that is needed but this question is more just plain Go.
So I have working routing in my application and I want to start implementing middleware. What I need to do is try to create optional middle ware.
So here is the scenario I am thinking.
All routes will go through middleware handlers for errors and logging.
POST routes need to go through an authorization middleware
Basically I don't want my read routes to go through this auth.
However it could also make sense for them too as I think about it because I will have some private content you need to be logged in to see.
Can I do something like this where I parse the middleware even being in the chain based on the route being a post route?
Or would it be better to perhaps always go through the auth handler but that handler detects if it even needs to run or some similar options within the middleware portion?
Or would maybe it be better to skip chaining authorization in the middleware chaing and maybe just handle calling the auth handler is another handler determines it is necessary?
Ken