func MyHandler(ctx *middleware.Context) { id, err := ctx.QueryInt64("id") if err != nil { // handle error } // use id }
func MyMiddleware() middleware.Handler { return func(ctx *middleware.Context) { // do something if id, err := ctx.QueryInt64("id"); err == nil { // use id } // do something else ctx.Next() } }This example shows how to use the "Context QueryInt64" function in a middleware function. The function reads the "id" query parameter from the HTTP request context and assigns its value to the "id" variable of type int64. If the "id" key is not found or the value cannot be parsed as an int64, the function continues to the next middleware function in the chain using the "ctx.Next()" function.