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
2
votes
1 answer

POST to Gin fails when it comes from my Android app, but succeeds when from Postman

I'm not quite sure which side is the cause of the issue, but it seems that the request gets received by Gin but doesn't allow the request from the android app. The endpoint I'm trying to POST to is related to a monolith model which has a type…
rminaj
  • 560
  • 6
  • 28
2
votes
2 answers

htmx form + gin unable to properly read request body

I have this form using htmx, trying to send the input value of the first input to the Gin server
AyeAreEm
  • 353
  • 6
  • 14
2
votes
1 answer

Do we have any solutions for the Gin CORS issue with non-simple requests (POST JSON)?

Problem Description I have tried several solutions, but none of them worked. Here are the details: I have a website configured at localhost:8080, and I want this web app to access the Gin server at localhost:9999 using Axios. Here are the solutions…
Iteravse
  • 21
  • 2
2
votes
2 answers

Bugsnag is throwing invalid api key: '' error

I am using go v1.19 to build a go application. I have run this application using a service file in linux OS. Below in my code to initialize the bugsnag: package main import ( "github.com/bugsnag/bugsnag-go" bugsnaggin…
Amandeep kaur
  • 985
  • 3
  • 15
  • 35
2
votes
1 answer

Go Gin: Pass Zap Logger

I'm working in a project using Gin and recently started implementing a logger through the project. I saw a couple libraries but decided to go with uber's Zap. I've got controllers that look like this: package controllers func ListAllArtists(c…
MrCujo
  • 1,218
  • 3
  • 31
  • 56
2
votes
1 answer

Header-based versioning on golang

I would like to implement header-based versioning on go using gin. I'm thinking to do this on the router using a middleware function. The client will call the same API URL, and the version will be on a custom HTTP header, like this: To call version…
juan
  • 358
  • 1
  • 4
  • 12
2
votes
1 answer

Pushing golang app to cloud-foundry throws error in logs

I have a go app in the main.go file which has a server. The server is running on localhost:9090. I have my manifest.yaml: applications: - name: golang-app buildpacks: - https://github.com/cloudfoundry/go-buildpack memory: 4GB …
Zwen2012
  • 3,360
  • 9
  • 40
  • 67
2
votes
0 answers

Why doesn’t 'dive' work on gin? (about validator)

I just would like to do like the below about validation on Gin(Golang). type Accounts struct { Accounts []*Account `json:"accounts" binding:"required,dive"` } type Account struct { BusinessId string `json:"business_id"…
TomoEno
  • 21
  • 1
2
votes
1 answer

Avoid 404 on root route using Gin

I am working on a CMS project where the URL for the frontend is https://cms.example.com However, the backend routes start with /v1 which I have configured in gin as a Router Group engine.Group("/v1"). Hence a backend endpoint will be something like…
MRA1412
  • 57
  • 8
2
votes
1 answer

How to return nested entities after creating a new object?

Model Account contains nested structures - Currency and User When I create a new instance of Account in DB, and then return it in my response, nested entities are empty: type Account struct { BaseModel Name string …
2
votes
1 answer

how to do authorization with middleware - gin gonic go

i am learning to use middleware with gin framework and i am facing a problem I want my Test function to be displayed in postman only if it has the requirements of my func TokenAuthMiddleware but regardless of whether my body is filled in or not, my…
2
votes
1 answer

Create Query 'has one' relationship in reverse direction GORM

I am currently trying to create a new record using GORM and these two models has a one to one relationship with each other. Model1 has 'has one' relationship with Model2. I was thinking if it is possible to create query Model2 instead of Model1 in…
jmsandiegoo
  • 413
  • 4
  • 14
2
votes
1 answer

Is there any way to make two GET query parameters point to two different routes (handler functions) in Golang or GIN?

I am trying to do the following: /car?color= -> first route (endpoint) and first handler function /car?brand= -> second route (endpoint) and second handler function /car?type= -> third route (endpoint) and third handler function ... I tried the…
Filip
  • 401
  • 8
2
votes
2 answers

HTTP Request Validation Middleware In Go

I am trying to create a common HTTP request validator middleware function that accepts type (maybe reflect.Type) as an argument and then using the package github.com/go-playground/validator/v10 to be able to unmarshall JSON into struct of mentioned…
2
votes
1 answer

Golang Gin Binding Request body XML to Slice

I am having an issue with the default binding in Gin. I have an incoming request where the body is multiple Entity objects like so: Name One here ... Name Two here ... My goal…
Eric
  • 328
  • 4
  • 13