Where communities thrive

  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
Repo info
  • 12:30
    deepnum opened #2137
  • 11:56
    Coverage (#15879) +0.17%
  • 11:51
    Coverage (release) -0.03%
  • 11:36
    Coverage (#615) +0.01%
  • 09:04
    Coverage (#615) +0.03%
  • 09:03
    Coverage (#610) -0.14%
  • 02:00
    appleboy closed #12
  • 02:00
    appleboy commented #12
  • 01:59

    appleboy on master

    Made headers configurable (+ pa… (compare)

  • 01:59
    appleboy closed #17
  • 01:36

    appleboy on master

    docs: update example (compare)

  • 01:32
    appleboy closed #15
  • 01:32
    appleboy commented #15
  • 01:32

    appleboy on master

    *: gzip decompress supports (#3… (compare)

  • 01:32
    appleboy closed #32
  • Nov 16 22:29
    appleboy commented #1382
  • Nov 16 19:14
    Coverage (#15832) -0.32%
  • Nov 16 14:06
    Coverage (#614) +<.01%
  • Nov 16 10:42
    Coverage (release) -0.03%
  • Nov 16 09:47
    Coverage (#613) -0.03%
Phillip Couto
@moos3 for me I usually consider two options. Creating a table in a database to track them if I want to be able to expire them sooner or you create a link that uses an HMAC to verify the parameters in the link are valid.
The key for the HMAC can only be know by the application so that a malicious user can't craft their own.
Henri Idrovo

Hi I'm wondering how people handle environment specific configurations with a gin app, I'd love to hear how the community here handles that!

I have a gin app that reads from a cassandra db. So I want to setup up three different configurations for cassandra(dev, test, prod). Thanks!

@phillipCouto yeah I'm playing with tracking them now, just trying to figure out the HMAC
Hello every! First of all wanna say so much thank for gin, it is best of the best.
Second one, i create simple middleware package for check user on sing in or not, may be will be helpful for some one
Stanislav Valasek
I made a starter kit using Gin and Quasar, material design Vue.js framework. PRs, new feature requests, issues, and your feedback are welcomed. https://github.com/valasek/quasar-starter-kit-go-gin
Piyush Bhangale
I had a question, how can we get the params from the url.
With this, I mean that i have a path /i/<code>, where <code is what i want to get
How can I do that?
c.Params c.Query
Phillip Couto
@moos3 did you figure out HMAC?
hi there
Ryan Luo
hi there
Tiago Cardoso
Yo folks, is it possible to redirect a request to NoRoute handler?
Tiago Cardoso
any other way than use context Redirect to a route that doesn't exists?
Phillip Couto
@tiagoacardoso create the NoRoute handler as a separate function. Then in the code you want to redirect from just call your function and return to make sure nothing else runs.
Stefanos Chrs
Hello, I have a question, is there any way to skip logging the 200 status requests? There is not much documentation on the logger middleware from what I searched. I'm looking for something like https://github.com/expressjs/morgan#skip
Phillip Couto
@stefanoschrs I would create a new router with a custom middle ware that checks status code and if not 200 passes the context to the logger:
I would provide a code sample but I can't from my device. If you want I can type one up later when i am on my laptop.
I need your opinion of the my little module go for create CRUD on GORM. This module can work with mux or gingonic.
If you want help me, I will thank

other ide is use TableName
var suffix string

// Record is the one entity
type Record struct {
ID uint gorm:"primary_key" json:"id"
CreatedAt time.Time json:"created_at"
UpdatedAt time.Time json:"updated_at"
DeletedAt *time.Time json:"deleted_at"
Name string json:"name"

func (e Record) TableName() string {

return "record_" + suffix


and use suffix = "1"
suffix = "2"
I was wrong chat
question, when using a logger middle ware like zerolog, how do I call it in my handlers when I want to log errors?
Rohit Roy Chowdhury
How to validate if a json value was empty for a boolean field of a struct model?
John Napiorkowski
I'm studying custom validation (https://gin-gonic.com/docs/examples/custom-validators/) and wondering if there's a best practice approach when you custom validation needs to access the database (for example to enforce uniqueness for a username, or require a password to be different than the last 3). Some examples I find via Google suggest just making the DB handler global and adding the SQL directly into the registered validation method. Does that seem like the approach to take? I'm still new to Golang and the idea of a global makes me itchy.
thanks for anything responses, thoughts.
John Napiorkowski
a smaller question you might be able to answer, I can't seem to find online docs for the Gin API (for example c.ShouldBindWith). Is there an annotated API someplace or do you all just read the source code?
Riley J.
Reading the source code or using a search engine with the specific method is what I do
I am having issues with overwriting the 404 returned from NoRoute, I want it to be 200 and it will not set it correctly
Riley J.
nevermind, I got it figured out; I was writing the status after writing the content, which caused the 404. Writing the status first solved the problem
is this benchmark accurate?
Joel Mislav Kunst
hello, i have a more general golang question
Kaden Nelson
func AWSSession() gin.HandlerFunc {
    return func(c *gin.Context) {
        session := session.Must(session.NewSession())

        c.Set("AWSSession", session)


I'm using using this middleware to add an aws session to the Gin context. The session doc reads

Sessions should be cached when possible, because creating a new Session will load all configuration values from the environment, and config files each time the Session is created.

Is there a better way to initialize this session instead of initializing it on each middleware/api call?

Bruce Wang

Hello everyone, my name is Yong Wang. And I am a graduate student from Sun Yat-sen University, China. I am about to graduate in June next year. So I have to work on my graduation project pretty soon. Some of my friends have already started. My supervisor is pretty open to what project I am into. I am proficient at Go. And I have a fair amount of working knowledge of API gateway from the github.com/fagongzi/gateway project and microservices when I was doing an internship at Tencent Games. I am looking to work on an open-source project where my work could eventually be concluded as my graduation thesis. There is one requirement which is that my work on the graduation project needs to have at least two novel approaches to some problems. Is it feasible? If so, would you please suggest some problems that I can work on?

Looking forward to your replies. Any feedbacks are welcome.


Hi all, my name is shaurya, I was wondering if someone can explain to me how the validation of api calls made from client side once a user is authenticated. What I am trying to understand is given the backend is in go gin and the authentication system creates a session post login, user would have access to make api calls. Now in case of web app frontend which is opened in a browser would have the session assigned to it, wouldn't it be possible let's say by using a browser extension for rest api to query resources of a different user ? For example a query which returns notes of a user, with an endpoint /v1/mynotes with parameters userid can be manipulated of a different user and get all the notes ? How does this really work in real world applications ?
Why gin engine not work outside function?
I tried it didn't work. Inside function it works.
Thanabodee Charoenpiriyakij
@findridoy Could you provide an example?
Sean Murphy
Hi, Sorry to bother you all on here - I have a golang contract position in Rotterdam,Holland 6 months paying up to £800 a day looking for strong developers who are interested - if you are interested please contact me on sean@fullstack.london or DM me to find out more.
Phillip Couto
@KadenLNelson yes, create it in server startup and use a custom middleware to pass it in to the gin.Context. This is what I do with my current projects.
@roychowdhuryrohit-dev make the field *bool and it will be null and test if the value after parsing is null in your code
Anmol Sethi
Hello, could someone please review and merge gin-gonic/gin#2120 It's a very small fix.
Hey Guys, I am new to Go, I want to develop Microservices for Go, I was overwhelmed with the number of frameworks available, if anyone has any comparisons or opinions that would be helpful.