All Questions
14
questions
0
votes
0
answers
122
views
How to implement Access / Refresh Tokens
I have been reading up about multiple ways one can implement refresh/access token logic. I've received mixed answers on how to tackle it. My API currently requires username/password authentication ...
1
vote
1
answer
423
views
How to re-write response body in middleware?
I want to hide some fields in response body using a middleware. I'm using gin-gonic package as a router handler.
Here the middleware I build and tried,
type toolBodyWriter struct {
gin....
2
votes
1
answer
604
views
Gin and middleware
How to make a middleware so that it only works for some handlers (not for all)?
For example,
func (srv *server) Router(repository storage.Repository, cfg config.Flags) *gin.Engine {
h := handlers....
1
vote
2
answers
2k
views
How to rewrite the response body and empty the original content in the middleware?
Hope to output replace data, but output origin data+replace data or no output after trying
I want to rewrite response body in middleware,Only want to output replace data,Refer to How to rewrite ...
2
votes
2
answers
518
views
Gin middleware context variable not preserving
I am trying to get user's tasks by fetching them from database using user id gotten from gin context. The issue is in GetAllUsersTasks where userContext is <nil>. While in loggedIn the user from ...
1
vote
2
answers
8k
views
Golang Gin: Middleware with CORS not working
I've got a POST request from my frontend app to my backend app written in Go using Gin. I was getting an error saying:
"No 'Access-Control-Allow-Origin' header is present on the requested ...
0
votes
1
answer
2k
views
Golang Gin Middleware pass Data to Template
Hi currently i am doing a little project and i have question.
Is there a way to pass Data to a template from a Middleware?
For Example:
func CheckAuth(c *gin.Context) { //This Middleware gets the user ...
-1
votes
1
answer
801
views
Gin binding middleware always fail
Im trying to have custom error messages for gin validation & followed the advice in this thread: https://github.com/gin-gonic/gin/issues/430
Im trying the gin binding midddleware this way:
package ...
-1
votes
1
answer
147
views
Unable to access json data from request in request handler after calling BindJSON in middleware
I have created a basic CRUD API using Go-Gin. Calling BindJSON in request handler gives me a blank object after calling BindJSON in middleware but works fine if I remove BindJSON in middleware.
This ...
-1
votes
2
answers
3k
views
How can I get url in Gin middleware?
I want to do a A/B test in a Gin's middleware, I want to pass url:usermeta as a key-value to the A/B test service. How can I achieve this goal?Or any other grace way?
8
votes
3
answers
16k
views
Gin-Gonic middleware declaration
I'm using Gin-Gonic and I'm creating a custom middleware. See: https://github.com/gin-gonic/gin#custom-middleware
Is there a reason why the middlewares in the doc are written as such:
func ...
1
vote
2
answers
5k
views
How to implement efficient IP whitelist in gin-gonic/gin middleware
I have an application which I need to restrict to a handful of IPs. I can write a middleware and return if request IP is not from allowed list, however I would like this process to be as efficient as ...
1
vote
2
answers
4k
views
Gin If `request body` bound in middleware, c.Request.Body become 0
My API server has middle ware which is getting token from request header.
If it access is correct, its go next function.
But request went to middle ware and went to next function, c.Request.Body ...
1
vote
1
answer
6k
views
Creating a variable of type from interface in golang
I am trying to create validator/binder middleware in go using gin framework.
This is the model
type LoginForm struct{
Email string `json:"email" form:"email" binding:"email,required"`
...