Questions tagged [gin]
52 questions
3
votes
1 answer
This is a question about Type "Engine" and "RouterGroup" provided by go language gin
r := gin.Default()
Default() function returns *Engine.
but r calls a function on RouterGroup.
ex)
r.GET("/api/healthcheck", func(c *gin.Context) {
c.JSON(200, gin.H{
"message": "hi",
})
})
Definition
// Engine…

naig
- 47
- 4
2
votes
0 answers
Gin local caching data within go routines
I have some golang gin application. Under the hood it launch several goroutines, that execute some sql queries. But some queries are identical. So I decide to use local data cache (within single gin request)
I tried using gin context but it doesn't…

Smirnov
- 137
- 3
- 12
2
votes
1 answer
Criss Cross Address Deduplication
I have a db table persons in which only persons details are captured. Say Name, Father Name, Email, DOB, Proof of Address, Proof of Identity ,Pincode etc. and I have an address table in which address of the persons are stored say Address, Pincode,…

Akhilesh mahajan
- 104
- 6
2
votes
3 answers
Unable to read form-data in postman
I'm trying to read files from a struct array but I'm unable to read it. Here is the postman.
Here is my code:
type MasterTemplate struct {
ID uuid.UUID `form:"id" json:"id"`
IsVoice bool `form:"is_voice" json:"is_voice"`
…

Daniel Tenkorang
- 31
- 3
2
votes
1 answer
CodeQL: Gin / MongoDB API - Database query built from user-controlled sources error
I have a simple Golang Gin API that uses MongoDB as the backend database. My team is using GitHub CodeQL, so we want to be sure we are following the best standards. However, we continue to get this error for all of our query endpoints:
Database…

Kyle Barnes
- 729
- 3
- 13
- 22
2
votes
1 answer
CORS Error in Golang with Gin after Redirect
I'm trying to implement google oauth2 in my web server written in Go with gin. I've added two new endpoints called /google/sign-in and /google/callback. The first received the request and redirect to google auth url, and the second is called after…

carloberd
- 101
- 10
2
votes
1 answer
How to _not_ strip HTML comments from a HTML template in gin gonic
I'm using Gin Gonic with a HTML template file.
My template file contains (multi line) HTML comments of the kind .
I want that the HTML content is preserved in the output which is returned by
c.HTML(http.StatusOK,…

koks der drache
- 1,398
- 1
- 16
- 33
2
votes
1 answer
Additional "id" field generated when posting into MongoDB
I'm learning Go and Gin framework.
I built a simple microservice connected to a MongoDB collection, everything works but when I add a document using a POST it adds the "id" field instead of generating the key "_id" field, is there a way to avoid…
user20174493
2
votes
2 answers
Go Gin : Creating generic custom validators
I am using go Gin to create APIs in my project. I have requirement to create custom validators so I created like:
var valueone validator.Func = func(fl validator.FieldLevel) bool {
value, ok := fl.Field()
if ok {
if value != "one" {
…

Hemant Kumar
- 161
- 7
2
votes
0 answers
GO Gin framwork,Use embed to package front-end and back-end projects together. use the StaticFS for static resources with / prefixed routes
When using GO's Gin framework, package the front-end built dist project into the same bin scenario, and when the static resources of the front-end file are routed for requests, if it is a routing address starting with /, gin will report an error …

youngsh
- 21
- 1
2
votes
0 answers
Cookie not setting on iPhone with Gin-Gonic
My platform works fine on andriod and pc browsers. But when I try making a requests on iPhone, it returns http: named cookie not present
I'm using gin-gonic framework to set the cookie and everything works fine as expected unless iPhone or probably…

Lawrence Segun
- 53
- 3
2
votes
1 answer
Gin and middleware
How to make a middleware so that it only works for some handlers (not for all)?
For example,
func (srv *server) Router(repository storage.Repository, cfg config.Flags) *gin.Engine {
h := handlers.NewHandlerProvider()
m :=…

volnistii11
- 119
- 8
2
votes
1 answer
golang gin get cookie json
I use gin@v1.9.0
Trying to get cookie from request
Cookie example:
key={"ckey": "cvalue"}
code:
token, err := c.Request.Cookie("key")
Returns error
http: named cookie not present
But without curly braces, works fine
Cookie…

Alan Millirud
- 1,049
- 7
- 14
1
vote
0 answers
Gorm.Model ID as UUID with Mysql not allowing creation of data
I'm writing a Go (1.20) backend in Gin (v1.9.1) backend with Gorm (1.25.3), and for my data models I want to use UUID's as the ID. I've been trying to find a way to do this but always end up getting new errors when I try saving a new model into the…
1
vote
1 answer
How could I send files to different servers in a process when using gin?
I was trying to send files to different servers by creat a POST request and send it.In my process I tried to send 3 POST, one to the first server and rest to another.
However it works only the first POST request,the rest requests get a 200 code but…

xzy-bit
- 21
- 2