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
    There are lots of such projects there
    that is a good start
    session handling is there too
    @Slacki are you there?
    Kacper Czochara
    @Slacki
    yeah
    but is it written in utron?
    Geofrey Ernest
    @gernest
    nope
    but Golang
    Utron is a framework
    You can use all sorts of libraries and stuffs with it
    Kacper Czochara
    @Slacki
    can we consider i want to use gorilla/session package
    how would you compose it with utron
    so that for example check whether user is logged in or not is fired up on selected controller methods
    where should i initialize it's storage, as in documentation
    so that i can access it in controllers package
    Geofrey Ernest
    @gernest
    The gorilla session api is simple
    do it in an init function, either in the models or controllers
    there is endless possibiilities
    Kacper Czochara
    @Slacki
    and then i should check for user's session in each controller method?
    Geofrey Ernest
    @gernest
    You just need to know why you need to do it.
    and you can even stuck it into Context
    Kacper Czochara
    @Slacki
    okay one more thing
    Geofrey Ernest
    @gernest
    You can do the check in a middleware
    Kacper Czochara
    @Slacki
    there are several files in controllers package
    for example user.go, post.go, etc
    where should I put the init func
    Geofrey Ernest
    @gernest
    a good way is to have a middleware that checks for user's session
    Kacper Czochara
    @Slacki
    i was thinking about the middleware, but where should I place it? in main.go?
    Geofrey Ernest
    @gernest
    you can do that in many ways, easies is in controller package
    create a new file maybe and define the middleware there
    @Slacki sorry, I have to go now
    Kacper Czochara
    @Slacki
    okay, seeya
    Kacper Czochara
    @Slacki
    Geofrey Ernest
    @gernest
    @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