Gin is a web framework written in Golang. It features a Martini-like API with much better performance -- up to 40 times faster. If you need smashing performance, get yourself some Gin.
+null%
+null%
+null%
+null%
In my application I store a map of all my templates (map[string]*template.Template
) in an ApplicationEngine
struct, which is my application framework instance. I am currently using the standard context.Context
to pass request scoped values between my middlewares and handlers. I need a way to access that map of templates in order to render a specific template file.
I was looking at the way gin handles this, and found that gin uses a custom struct that stores a pointer to gin.Engine
, which is their application framework instance. It then has a HTML()
function on the context struct, which accesses the template map stored in the gin.Engine
pointer. Is there any specific reason that gin uses a custom struct instead of the standard context.Context
? Some people seem to think that this is a bad idea.
type GetTxListIM struct {
Page uint64 `form:"page" default:"1"`
Rows uint8 `form:"rows" default:"10"`
//ContractCall=1,Transfer=2,ContractCreation=3
Type []uint64 `form:"type"`
}
This is the structure content of the data I want to get
//@Param GetTxListIM query transaction_dto.GetTxListIM true "GetTxListIM"
//@Success 200 {object} transaction_dto.TxListOM
//@Failure 400 ""
//@Failure 500 ""
//@Router /Transaction/GetTransactionList [get]
func (controller *TransactionController) GetTransactionList(c *gin.Context) {
var input transaction_dto.GetTxListIM
if err := c.ShouldBind(&input); err != nil {
log.Errorln(err)
}
}
This is the Get method, here to parse the data
relativePath
as a .Param()
I have r.PUT("template/:path", template.PutTemplate)
and if I call it with template/path/to/my/template.txt
I want .Param("path")
to return path/to/my/template.txt
is this possible?
Hello o/,
Is there any way to use multiple authentication middlewares for the same route ?
We use https://github.com/appleboy/gin-jwt and a custom auth middleware based on generated tokens in the database, but we're unable to set them for the same route. If someone has a solution or a workaround to be able to authenticate users from jwt token or from the generated token please.
r.Use(static.Serve("/", static.LocalFile("../frontend/dist", false)))