Initial commit

This commit is contained in:
nemunaire 2022-10-21 23:54:17 +02:00
commit 0a854f708a
17 changed files with 796 additions and 0 deletions

30
api/api.go Normal file
View file

@ -0,0 +1,30 @@
package api
import (
"fmt"
"time"
"github.com/gin-gonic/gin"
)
type apiMetadata struct {
Call string `json:"call"`
Date time.Time `json:"date"`
Version int `json:"version"`
}
type apiResult struct {
Result interface{} `json:"result"`
Metadata apiMetadata `json:"_metadata"`
}
func APIResult(c *gin.Context, res interface{}) apiResult {
return apiResult{
Result: res,
Metadata: apiMetadata{
Call: fmt.Sprintf("%s %s", c.Request.Method, c.Request.URL.Path),
Date: time.Now(),
Version: 4,
},
}
}