Initial commit
This commit is contained in:
commit
0a854f708a
17 changed files with 796 additions and 0 deletions
30
api/api.go
Normal file
30
api/api.go
Normal 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,
|
||||
},
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue