Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Geofrey Ernest
    @gernest
    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
    It will be easy that way
    As globals are discouraged in Go
    Kacper Czochara
    @Slacki
    I don't really like this solution, because middleware is fired up on each request
    But I guess that's not big performance impact with this one assign, right?
    Geofrey Ernest
    @gernest
    you can check if it hasnt been assigned yet
    Kacper Czochara
    @Slacki
    Okay, thanks
    btw, what's up with my issue?
    I've tried to solve this
    but failed
    Geofrey Ernest
    @gernest
    I'm at work right now, I cant address the issue yet. Be patiend.
    Kacper Czochara
    @Slacki
    Sure thing.
    Thanks again
    Geofrey Ernest
    @gernest
    You are welcome
    Kacper Czochara
    @Slacki
    @gernest how can I achieve nested templates with utron? For example
    [HEADER HERE]
    some html
    [FOOTER HERE]
    I get no such template error using {{template "header.html"}}
    Kacper Czochara
    @Slacki
    By the way I'm sorry for beeing obtrusive... You're very patient and helpful.
    Geofrey Ernest
    @gernest
    @Slacki its okay, I actually don't mind .
    you just don't need to add the extension. Instead of {{template "header.html"}} try {{template "header"}}
    just make sure in the views directory there is header.html file
    Kacper Czochara
    @Slacki
    Works like a charm. Thanks. How does this happen?
    Geofrey Ernest
    @gernest
    It is a feature, to help easy templating with utron