1
0
Fork 1
mirror of https://github.com/thatmattlove/hyperglass.git synced 2026-01-17 00:38:06 +00:00
thatmattlove-hyperglass/core/interfaces/query.go
2023-07-24 10:57:09 -04:00

36 lines
737 B
Go

package interfaces
import (
"time"
"github.com/go-playground/validator/v10"
"github.com/gofiber/fiber/v2"
"github.com/thatmattlove/hyperglass/core/entities"
)
type QueryInterface struct {
Ctx *fiber.Ctx
Request *entities.QueryRequest
}
func (qi *QueryInterface) Query() (res any, err error) {
res = &entities.PlainQueryResponse{
Random: "random string",
Cached: false,
Runtime: 30,
Timestamp: time.Now(),
Format: "text/plain",
Output: "some output",
}
validate := validator.New()
err = validate.Struct(res)
return
}
func NewQueryInterface(ctx *fiber.Ctx, req *entities.QueryRequest) (iface *QueryInterface, err error) {
iface = &QueryInterface{
Ctx: ctx,
Request: req,
}
return
}