You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

21 lines
410 B

4 years ago
  1. package api
  2. import (
  3. "github.com/gin-gonic/gin"
  4. "github.com/gissleh/stufflog/internal/slerrors"
  5. )
  6. func handler(key string, callback func(c *gin.Context) (interface{}, error)) gin.HandlerFunc {
  7. return func(c *gin.Context) {
  8. res, err := callback(c)
  9. if err != nil {
  10. slerrors.Respond(c, err)
  11. return
  12. }
  13. resJson := make(map[string]interface{}, 1)
  14. resJson[key] = res
  15. c.JSON(200, resJson)
  16. }
  17. }