Go/Gin: Conditionally load or add another middleware in the chain during current middleware
When using Gin framework for Go, I’m writing some custom middleware. One of my new middleware will evaluate if the request coming in is from my front-end SPA. If it is, I want to also use the sessions middleware to create/load the user session info. If it is not, then I don’t want to call that middleware.
Golang Gin – Bind nested array using binding: “required” tag
I’m trying to unmarshal a request using c.ShouldBindBodyWith(&UserObj, binding.JSON).
I’m using the below structs:
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 modifying the timeout to return whatever result the handlers produce, like this:
Why can’t I initialize a struct from another package in Golang?
screenshot
How can I pass a database Instance from my route.go to my controller.go file?
I need to pass a database instance from my route.go file to a controller file in gin.
Unable to Load CSS Files in Gin Framework Project
I’m currently working on a project using the Gin framework. My HTML templates and assets are located within the “front” directory, and within it, I have CSS files. Despite correctly specifying the paths in the templates, my CSS files are not loading. What could be the reason for this?