Add Version

This commit is contained in:
Gianni Carafa
2023-11-02 22:05:57 +01:00
parent e748cb09a5
commit 7f4d749c55

View File

@@ -1,7 +1,8 @@
package handlers package handlers
import ( import (
"io" _ "embed"
"log" "log"
"net/http" "net/http"
"net/url" "net/url"
@@ -9,6 +10,9 @@ import (
"github.com/gofiber/fiber/v2" "github.com/gofiber/fiber/v2"
) )
//go:embed VERSION
var version string
func Api(c *fiber.Ctx) error { func Api(c *fiber.Ctx) error {
// Get the url from the URL // Get the url from the URL
urlQuery := c.Params("*") urlQuery := c.Params("*")
@@ -41,7 +45,8 @@ func Api(c *fiber.Ctx) error {
} }
body := rewriteHtml(bodyB, u) body := rewriteHtml(bodyB, u)
response := Response{ response := Response{
Body: body, Version: version,
Body: body,
} }
response.Request.Headers = make([]interface{}, 0) response.Request.Headers = make([]interface{}, 0)
for k, v := range req.Header { for k, v := range req.Header {
@@ -63,6 +68,7 @@ func Api(c *fiber.Ctx) error {
} }
type Response struct { type Response struct {
Version string `json:"version"`
Body string `json:"body"` Body string `json:"body"`
Request struct { Request struct {
Headers []interface{} `json:"headers"` Headers []interface{} `json:"headers"`