Re: [go-nuts] How to apply middleware

2019-04-05 Thread afriyie . abraham
Hi, Yes this make sense and it works. The code also look simple to read. Thanks!! On Thursday, April 4, 2019 at 7:54:27 PM UTC+3, car...@hotmail.com wrote: > > How about something like this? Unsure about concurrent access to global > variables, but if you want to access srv and clientstore

Re: [go-nuts] How to apply middleware

2019-04-04 Thread Burak Serdar
On Thu, Apr 4, 2019 at 2:44 AM wrote: > > I have modify the middleware to the below but it only work if the handler > function "/protected" is in the main function. > I have many handlers and do not want to put all of them in the main.go. > You suggest i define a struct and use member function

Re: [go-nuts] How to apply middleware

2019-04-04 Thread Burak Serdar
On Thu, Apr 4, 2019 at 1:46 AM wrote: > > changing and using "router.Use(getTokenMW(server))" is validating all the > routes. How can i exclude routes > /oauth2/token and /credentials. I read that populate but i dont get the idea. > Any clew about how to go about this? You can use subrouters:

Re: [go-nuts] How to apply middleware

2019-04-04 Thread caradke
How about something like this? Unsure about concurrent access to global variables, but if you want to access srv and clientstore from package sw, It'd make sense to me to move srv and clientstore out of main and into a package. howToApplyMiddleware main.go - server server.go - sw handler.go

Re: [go-nuts] How to apply middleware

2019-04-04 Thread afriyie . abraham
I have modify the middleware to the below but it only work if the handler function "/protected" is in the main function. I have many handlers and do not want to put all of them in the main.go. You suggest i define a struct and use member function of the struct, can you elaborate more about for

Re: [go-nuts] How to apply middleware

2019-04-04 Thread afriyie . abraham
changing and using "router.Use(getTokenMW(server))" is validating all the routes. How can i exclude routes /oauth2/token and /credentials. I read that populate but i dont get the idea. Any clew about how to go about this? On Wednesday, April 3, 2019 at 6:47:12 PM UTC+3, Burak Serdar wrote: >

Re: [go-nuts] How to apply middleware

2019-04-03 Thread Burak Serdar
On Wed, Apr 3, 2019 at 8:35 AM wrote: > type Route struct { > Namestring > Method string > Pattern string > HandlerFunc http.HandlerFunc > } > > type Routes []Route > > func NewRouter() *mux.Router { > router := mux.NewRouter().StrictSlash(true) > for _,

[go-nuts] How to apply middleware

2019-04-03 Thread afriyie . abraham
Hi, I have this main function in a main.go file inside the main directory func main() { log.Printf("Server started") router := sw.NewRouter() manager := manage.NewDefaultManager() manager.SetAuthorizeCodeTokenCfg(manage.DefaultAuthorizeCodeTokenCfg)