@Slacki yes it is a typo, you can help fix and submit a PR if you dont mind. I will look to it later. Thanks man.
Geofrey Ernest
@gernest
@Slacki thanks for the contribution
Kacper Czochara
@Slacki
@gernest that's one line that i've changed, no need to thank me
Geofrey Ernest
@gernest
:+1:
Kacper Czochara
@Slacki
@gernest i got middlewares to work for me. is it possible to modify Context inside a middleware function? If so, how can I achieve that?
For example if I check whether user is signed in, how can I pass the boolean containing that information to Context so I can access it in controller method?
Geofrey Ernest
@gernest
@Slacki that is nice to hear
will be back in a moment. Its dinner time here. :smile:
Geofrey Ernest
@gernest
I'm back
Geofrey Ernest
@gernest
@Slacki use gorilla context to do that. I did implement Context.GetData but I forgot to implement Conext.SetData
I am working on this right now
Geofrey Ernest
@gernest
@Slacki done, use *Context.SetData to store key value pair and *Context.GetData to retrieve the value.
dont forget to get the latest changes first by go get -u github.com/gernest/utron
enjoy
_
Kacper Czochara
@Slacki
Thank you for this. @gernest
Geofrey Ernest
@gernest
@Slacki you are welcome
Kacper Czochara
@Slacki
@gernest How can I access database globally? Is it possible or it's accessible only in controller method?
Geofrey Ernest
@gernest
@Slacki only theough the controller
Kacper Czochara
@Slacki
So what do you suggest in case I want some go routine running in the background which uses database
@gernest
Geofrey Ernest
@gernest
and also through *Context which is literally the one accessed in the controller
You don't have have to
Kacper Czochara
@Slacki
well, in this project I have to ;)
Geofrey Ernest
@gernest
why?
The Database connection is already a global like object( only one object passed around)
And there is already a connection pool taken care for you
Kacper Czochara
@Slacki
I am aware of that
Geofrey Ernest
@gernest
okay
Kacper Czochara
@Slacki
I just find it easy to process some data with goroutine
Geofrey Ernest
@gernest
I see
Kacper Czochara
@Slacki
I think when database connection is open it should be accessible globally
In PHP I would use some cron tasks to do what I need to do
but goroutine is just perfect solution
If I only could access DB there
Geofrey Ernest
@gernest
You know that the database is available in *Context right?
Kacper Czochara
@Slacki
Yes, but I don't know other ways of accessing *Context than in controller method or middleware
Geofrey Ernest
@gernest
So you can pass a middleware that pulls it and assigns to a global variable in your app