Questions tagged [go-gin]

Gin is a HTTP web framework written in Go.

It features a Martini-like API with much better performance -- up to 40 times faster. If you need smashing performance, get yourself some Gin.

Docs

GitHub

755 questions
4
votes
2 answers

How to log or print request received with gin?

Example: func createOrUpdateInfluencer(c *gin.Context) { } How to print the data in the request received in my function? In my case, I am supposed to receive JSON, how to print it without knowing what it looks like?
Bussiere
  • 500
  • 13
  • 60
  • 119
4
votes
1 answer

Folder structure and package naming convention for a REST API develop in Gin Framework

I was a NodeJS / PHP developer and I'm a beginner using Go. After doing a little research, I come up with a MVC style folder structure like this for my REST API project. . +- bin/ +- controllers/ +- userController/ +- userController.go +-…
Trevor. W
  • 451
  • 1
  • 5
  • 13
4
votes
1 answer

How can I have a parameter with slashes in gin url

I want to have a parameter with slashes in the router in gin. From what I gathered I can do this by adding a wildcard to the URL. For example: /api/v0/files/*addr But this approach doesn't work if I want to have the addr in the middle of the URL…
taraf
  • 777
  • 2
  • 10
  • 28
4
votes
2 answers

How to serve two static sites with gin in golang?

I want to create an application that will call a boolean function and depending on the result provide 1 of 2 compiled react apps as static sites. I'm using the LoadHTMLGlob function recommended by gin and it works fine with .tmpl files like the…
Jbar
  • 43
  • 1
  • 4
4
votes
3 answers

Cors doesnt work on gin and golang group routes

I try this specific code but it keep on giving me error in No 'Access-Control-Allow-Origin' package main import ( "github.com/gin-contrib/cors" "github.com/gin-gonic/gin" ) func main() { router := gin.Default() …
sinusGob
  • 4,053
  • 12
  • 46
  • 82
4
votes
1 answer

plugin was built with a different version of package

VM1 and VM2 both have go version 1.11.1. My Scenario: VM1: main.go package main func startGin() *gin.Engine { gin.SetMode(gin.ReleaseMode) router := gin.New() v1:= router.Group("/v1") all_plugins, err :=…
ajeyprasad
  • 41
  • 1
  • 3
4
votes
1 answer

Do I need to spawn multiple Go web server instances to fully utilize my CPU?

I'm not exactly sure how to ask this question but in my experience with NodeJS, which has a single thread and a process queue to manage async functions, you need to run an instance of your web server on seperate processes for each CPU thread - then…
David Alsh
  • 6,747
  • 6
  • 34
  • 60
4
votes
1 answer

How to add multiple groups to gin routing for api version inheritance?

I'm currently working on a API with Go + Gin. The API should include a version string, for example the string v1 http://127.0.0.1:3000/v1/user/get_username That is no problem, because I can create a group with Gin v1 :=…
Berti92
  • 441
  • 1
  • 6
  • 12
4
votes
2 answers

go-gin unable to set cookies

I am trying to set a cookie on an HTML page func testCookie(c *gin.Context) { c.SetCookie("test1", "testvalue", 10, "/", "", true, true) c.HTML(200, "dashboard", gin.H{ "title": "Dashboard", } } This should have set…
codec
  • 7,978
  • 26
  • 71
  • 127
4
votes
2 answers

Iterate through all PostForm values Gin Gonic

Is there an easy way to list / iterate through all post values using Gin Gonic? (Go) I have tried: c.Request.ParseForm() for key, value := range c.Request.PostForm { log.Printf("POST %v = %v",key,value) } But this shows no values, however when…
BadPirate
  • 25,802
  • 10
  • 92
  • 123
4
votes
5 answers

Golang Gin "c.Param undefined (type *gin.Context has no field or method Param)"

I tried to use the Gin which is framework for Golang. https://github.com/gin-gonic/gin And the I copied sample codes from official github. It's like this. package main import ( "github.com/gin-gonic/gin" "net/http" ) func main() { …
k16
  • 481
  • 2
  • 6
  • 18
4
votes
1 answer

Set map,struct to session in golang( gin gonic framework)

I am using gin gonic to build a web application. I use https://github.com/gin-gonic/contrib/tree/master/sessions to handle session. Forexample, i set a integer value to session: function Test(c *gin.Context){ session:= sessions.Default(c) …
Vutuz
  • 458
  • 1
  • 7
  • 19
4
votes
1 answer

How to return gzip response for golang gin framework

I'm trying to return a gzip response using the golang framework gin. They provide an example here: https://github.com/gin-gonic/contrib/blob/master/gzip/example/example.go package main import ( "fmt" "github.com/gin-gonic/contrib/gzip" …
Chris Passas
  • 91
  • 3
  • 7
4
votes
4 answers

How to make templates work with gin framework?

I am newbie to golang. To learn it I have started with a simple web app using gin framework. I have followed the gin doc & configured template file but not able to make it work. I am getting an error - panic: html/template: pattern matches no…
ameykpatil
  • 581
  • 1
  • 7
  • 21
4
votes
2 answers

gin gonic middleware, how to get failure/success status for next handler in chain

I am writing a middleware, using gin gonic golang framework. I want to know within my middleware, if the call to next handler failed and take action based on that. func foo() gin.HandlerFunc { //do something.. c.Next() //do something…
SeattleOrBayArea
  • 2,808
  • 6
  • 26
  • 38