All Questions
906
questions
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"...
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 ...
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 {
//...
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
...
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 ...
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 *...
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....
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 ...
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 ...
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 ...
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 ...
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:...
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 ...
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>
&...
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/...