go-gin Questions

8

Solved

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...
Nowhither asked 2/12, 2015 at 15:13

13

Solved

I'm using Go gin framework gin func CORSMiddleware() gin.HandlerFunc { return func(c *gin.Context) { c.Writer.Header().Set("Content-Type", "application/json") c.Writer.Header().Set("Access-Cont...
Clone asked 2/4, 2015 at 17:3

4

Solved

I am trying to restore the context with it's data after performing validation on it's data.I need the data to keep moving as need it later on in the next function. I am new to golang and the below ...
Foresee asked 5/7, 2020 at 4:30

4

Solved

I'm using GoLang and Gin Framework. I need to respond for REST API call with 204 response code without message body. How it is to do properly? What I could find by digging the source code c.JS...
Duisburg asked 23/10, 2014 at 20:54

2

How do I cancel further processing if the connection is closed before 10 seconds? There is c.Request.Context().Done() but coudn't find an example on how to use it. func main() { r := gin.Default()...
Libreville asked 5/7, 2020 at 11:38

6

Solved

I am looking at https://godoc.org/github.com/gin-gonic/gin documentation for a method which returns list of all the query parameters passed. There are methods which return value of a query paramete...
Mailemailed asked 22/12, 2016 at 9:2

3

I try to validate if enum is valid in Golang using Gin framework. I came across this solution: Use enum validation in golang with gin with custom error messages But disadvantage of this approach ...
Redware asked 26/2, 2022 at 17:14

5

Solved

I've just started trying out Go, and I'm looking to re-implement an API server written in node with it. I've hit a hurdle with trying to use dependency injection to pass around a database context ...
Dialect asked 27/2, 2016 at 17:17

3

Solved

I am setting up a small API using Go Gin, however I am unable to convince the logger to output JSON. By default it's a key/value string, but I need it as json. How can I achieve that? I feel it sh...
Tasha asked 29/4, 2020 at 9:50

4

Solved

I'm a newbie when it comes to Go and Gin, so please excuse my ignorance. I've setup a server using Gin which supports a POST request. I would like the user to POST their request which includes a r...
Bacchius asked 7/10, 2016 at 16:46

5

I have built a go application using gin and go1.17. I am using go:embed to to serve static content for a SPA app built using react. (trying the approach as suggested in https://github.com/gin-contr...
Oram asked 6/10, 2021 at 8:37

2

Solved

I want to serve a JSON file with gin server. And set some customize values in the HTML file. Use JavaScript in it to call the JSON file. My application structure: . ├── main.go └── templates ├── i...
Bueno asked 5/8, 2019 at 7:55

2

Solved

I want to grab all http errors on each route without rewrite each time if 400 then if 404 then if 500 then etc... so I have an ErrorHandler() function inside each route handler: func (h *Handler) L...
Ozonide asked 12/11, 2021 at 20:38

3

Solved

I want to get the header data using gin package(golang) in the postman but I don't get any idea how to do it. I search it for google but not getting any answer. Can anyone help me to get the data f...
Locket asked 19/4, 2018 at 5:22

1

I build a Go server in Gin framework and now I want to deploy it to GCP. I am trying to run docker compose up -d on VM in GCP Compute Engine. The command successfully runs in my local machine but s...
Municipality asked 17/10, 2022 at 16:55

1

I'm using SAM. The following setup works: Function: Type: AWS::Serverless::Function Properties: CodeUri: ./code/ Runtime: go1.x MemorySize: 64 Handler: main Events: TesstApi: Type: Api ...
Oneeyed asked 13/4, 2020 at 17:20

2

Solved

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...
Clerihew asked 7/9, 2015 at 17:41

2

I'm setting up testing in golang. I use go-sqlmock to test mysql connection. But sqlmock.NewRows and mock.ExpectQuery does not work well with error. I want to know how to resolve this error. serve...
Astrict asked 30/8, 2019 at 1:7

1

Solved

I have a News structure, I want to display them in descending date order. But he displays them to me by id in the usual way Struct: type News struct { Id int `json:"id" gorm:"primar...
Cariotta asked 18/7, 2022 at 16:5

2

Is there a way to generate OpenAPI spec files from a gin project? This issue is really hard to search for, all I could find so far are on doing there reverse.
Asseveration asked 23/5, 2022 at 12:46

3

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() { ...
Fancier asked 13/2, 2019 at 8:18

3

Solved

I'm a newbie on Golang, and I'm trying to use Gin to develop a web server on Ubuntu 16.04. After executing go get -u github.com/gin-gonic/gin, many folders appear at ~/go/pkg/mod/github.com/. The...
Hokku asked 8/4, 2020 at 1:14

2

In one of my API's I mostly return a result (let's say paged 50 results) as one whole in an json array like so: [{},{},{},{},{},...] I was wondering if there are better ways of doing this over H...
Variform asked 12/6, 2016 at 21:15

2

Solved

I have created two different Groups for gin routing specifically /user and /todo in two different packages and I want to merge them into one file . Here is my userroutes.go file. package user...
Peace asked 27/6, 2020 at 9:48

1

For a given route with path param (example below) router.GET("/employee/:id", empHandler.GetEmployee) When tried to invoke the url with id path-param(encoded) containing forward slashes ...
Selfsufficient asked 23/3, 2022 at 4:25

© 2022 - 2024 — McMap. All rights reserved.