All Questions
900
questions
2
votes
1
answer
19
views
gin router 404 on url patterns with :id parameter
I am getting a 404 error from a URL pattern with a quite simple parameter in it.
I am using gin-gonic with golang.
Here is my main programme. I've removed all other routing to isolate the problem.
...
0
votes
1
answer
51
views
Parsing path parameters dynamically from request url
I am working on a project using the fiber/v2 router, for a request mocking service. Now parameters passed via request body and query parameters are not an issue and handled easily. But here lies the ...
-2
votes
0
answers
25
views
Golang test cases for gin failing [closed]
Hi All I am trying to create a test cases for my gin gonic framework where I am using Gorm and ORM but I am getting errors like this:
[31m2024/07/03 08:48:19 [Recovery] 2024/07/03 - 08:48:19 panic ...
-1
votes
1
answer
43
views
Cannot use exported method that belongs to the package in Golang
I've got a package named services. This is the structure of the package:
services/
third_party/
discogs.go
discogsAPIStructs.go
artist_srv.go
auth_srv.go
record_srv.go
...
1
vote
0
answers
11
views
HTMLGlob template pattern matching with nested subdirectories
I am working on a golang project using gin and go templating.
My templates are in a structure like so:
C:.
├───components
├───display
....
I would like to add subdirectories to organise the templates,...
1
vote
1
answer
61
views
Problem with Sending Data through Channel with Gin Context
I create a timeout middleware and I keep getting a warning that says 'Headers were already written. Wanted to override status code 504 with 500' whenever it times out. I want to avoid that warning by ...
1
vote
0
answers
44
views
How i can fetch session data?
I try to fetch some session data using a svelte frontend and i get a response status 401
This is the code that i use for the cors
router.Use(cors.New(cors.Config{
AllowOrigins: []string{&...
1
vote
0
answers
40
views
err.Translate(trans) only works if translator passed via param (go-playground/validator)
I'm trying to translate the validation errors message because I don't like the default error message. When I pass the trans variable via param from controllers to a helper (to handle validation error),...
2
votes
0
answers
112
views
Unable to retrieve session value in Go Gin
Problem: The session data set during login is not persisting across subsequent requests.
Expected output: The session data set during login should be stored and is accessible persist requests.
func (...
0
votes
2
answers
67
views
How can I respond back on same gin context if response to be sent is received on some other endpoint
So, I have to handle sync call in async way.
My go microservice using gin context receives request on /req endpoint, and I have to send it to some other microservice say B, after performing ...
2
votes
0
answers
82
views
Gin cors middleware not working with Group()
When using gin-contrib/cors middleware directly in the default router, it works perfectly fine for any url, but when I create a group using r.Group("/api"), the cors does not apply to any of ...
1
vote
1
answer
60
views
Getting cors errors after fetching to gin server, even *SWITCHED* to another backend
Access-Control-Allow-Origin is properly set to '*';
Tried using nestjs as backend with the same address, works perfectly fine.
But when using gin, although the header is properly set, still get the ...
-1
votes
2
answers
86
views
How can I pass a database Instance from my route.go to my controller.go file? [duplicate]
I need to pass a database instance from my route.go file to a controller file in gin.
I tried passing the Server Struct But I'm getting a circular import. Also, I cant use any of *sql.DB function even ...
2
votes
0
answers
38
views
how to configure my nginx on docker compose?
I have a some service by running via the docker-compose. as below :
I have my nginx config as below:
# 设置客户端请求体大小限制
client_max_body_size 20M;
# 设置WebDAV方法
dav_methods PUT DELETE;
error_log /var/log/...
2
votes
2
answers
98
views
golang gin when to use handleContext and when redirect
Having processed a GET request, I want to redirect the user to a new URL, handled by my app, which displays the results.
In the gin documentation I found two different ways to do this. One is to use ...