Skip to main content

All Questions

Tagged with
1 vote
1 answer
5k views

Configure gin-gonic session using Redis in Golang

I am using gin-gonic in Go and using Redis session feature provided in github.com/gin-gonic/contrib/sessions package store, _ := sessions.NewRedisStore(10, "tcp", "localhost:6379", "", []byte("secret"...
Eddie's user avatar
  • 767
2 votes
1 answer
4k views

Accessing route in middleware using Gin

I have a user.save route (below) in my Golang API that can be used to create and update a user depending on whether an id was provided in the request object. The route uses the auth middleware which ...
tommyd456's user avatar
  • 10.6k
4 votes
2 answers
6k views

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 { //...
SeattleOrBayArea's user avatar
49 votes
8 answers
49k views

How to pass arguments to router handlers in Golang using Gin web framework?

I'm using Gin, https://gin-gonic.github.io/gin/, to build a simple RESTful JSON API with Golang. The routes are setup with something like this: func testRouteHandler(c *gin.Context) { // do smth ...
Niklas9's user avatar
  • 9,226
5 votes
2 answers
19k views

Changing default header for JSON data in Gin

I've noticed that using Gin to return a response like this: c.JSON(http.StatusOK, jsonData) automatically creates the following header: application/json; charset=utf-8 Is it possible to modify the ...
tommyd456's user avatar
  • 10.6k
3 votes
1 answer
4k views

Is there anyway to close client request in golang/gin?

Using gin framework. Is there anyway to notify client to close request connection, then server handler can do any back-ground jobs without letting the clients to wait on the connection? func Test(c *...
fannheyward's user avatar
2 votes
2 answers
6k views

Failed to Abort() context - gin

I have the following Gin middleware: func CheckAppId(appC *core.Context) gin.HandlerFunc { return func(c *gin.Context) { //get Basic Auth credentials appId, token, _ := c.Request....
tommyd456's user avatar
  • 10.6k
1 vote
1 answer
2k views

Get BasicAuth creds in Gin

I have made a switch to Gin to try it out. Before the move I accessed the BasicAuth credentials (app_id and token) using the request object like this: appId, token, _ := r.BasicAuth() The app_id ...
tommyd456's user avatar
  • 10.6k
34 votes
2 answers
34k views

Setting up Route Not Found in Gin

I've setup a default router and some routes in Gin: router := gin.Default() router.POST("/users", save) router.GET("/users",getAll) but how do I handle 404 Route Not Found in Gin? Originally, I was ...
tommyd456's user avatar
  • 10.6k
6 votes
3 answers
32k views

How to use Context.Request.Body and retain it?

I am trying to write a middleware where I will be doing a json schema validation against the request body. After the validation, I need to use the request body again. But I am not able to figure out ...
Sanath Ballal's user avatar
10 votes
1 answer
1k views

same code but different results using gin + go-template

Basic information Go version: go1.4.2 darwin/amd64 Operating System: Mac OS X 10.10.5 I'm working on a small Web project written based on go and gin. Here is my golang code. After running go run ...
Miaonster's user avatar
  • 1,512
9 votes
1 answer
22k views

gin/golang - Empty Req Body

I'm new to Go and Gin, and am having trouble printing out the full request body. I want to be able to read the request body from third party POST, but I'm getting empty request body curl -u dumbuser:...
Leon Hu's user avatar
  • 137
0 votes
2 answers
6k views

Multipart File Upload Validation in gin-gonic

I am trying to add validation for the go based web application based on GIN framework. On the web page I am selecting a file and submitting and the server is processing it. On the server side I am ...
Kunal Jha's user avatar
  • 2,142
1 vote
1 answer
2k views

Bind multiple values in gonic-gin [duplicate]

I have a form like this: <form action="post" method="post"> <select name="message" multiple> <option value="volvo">Volvo</option> &...
chuyen tx's user avatar
0 votes
2 answers
2k views

Golang slices of struct or newbie trouble building REST

and need your help. Wanted to build simple api and stuck with some problem. I've choose gin and database/sql with postgres driver package main import ( "database/sql" "fmt" "github.com/...
Painhardcore's user avatar

15 30 50 per page