second commit
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
package v1
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// handlerTestResponse is a shared response struct for unmarshalling handler test JSON output.
|
||||
type handlerTestResponse struct {
|
||||
Success bool `json:"success"`
|
||||
Data interface{} `json:"data"`
|
||||
}
|
||||
|
||||
// mockAuthMiddleware simulates auth middleware for edge-case tests.
|
||||
// Sets user_id=1 and extracts account_id from URL param.
|
||||
func mockAuthMiddleware() gin.HandlerFunc {
|
||||
return func(c *gin.Context) {
|
||||
c.Set("user_id", uint(1))
|
||||
if accID, err := strconv.ParseUint(c.Param("account_id"), 10, 32); err == nil {
|
||||
c.Set("account_id", uint(accID))
|
||||
}
|
||||
c.Next()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user