mirror of
https://github.com/khairul169/vaulterm.git
synced 2026-09-15 17:03:30 +07:00
feat: init api, db, app
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
package utils
|
||||
|
||||
import "github.com/gofiber/fiber/v2"
|
||||
|
||||
func ResponseError(c *fiber.Ctx, err error, status int) error {
|
||||
if status == 0 {
|
||||
status = fiber.StatusInternalServerError
|
||||
}
|
||||
|
||||
return &fiber.Error{
|
||||
Code: status,
|
||||
Message: err.Error(),
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package utils
|
||||
|
||||
import "encoding/json"
|
||||
|
||||
func ParseMapInterface(data interface{}, out interface{}) error {
|
||||
// Marshal the map to JSON
|
||||
jsonData, err := json.Marshal(data)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Unmarshal the JSON data into the struct
|
||||
err = json.Unmarshal(jsonData, &out)
|
||||
return err
|
||||
}
|
||||
Reference in New Issue
Block a user