59 lines
960 B
Go
59 lines
960 B
Go
package main
|
|
|
|
import (
|
|
"log"
|
|
"os"
|
|
|
|
"github.com/gofiber/cors"
|
|
"github.com/gofiber/fiber/v2"
|
|
)
|
|
|
|
type TestInfo struct {
|
|
Id int `json:"id"`
|
|
Name string `json:"name"`
|
|
}
|
|
|
|
func main() {
|
|
app := fiber.New()
|
|
|
|
app.Use(cors.New())
|
|
|
|
app.Static("/", "./build")
|
|
|
|
app.Get("/api/", func(c *fiber.Ctx) error {
|
|
|
|
a := TestInfo{
|
|
Id: 1,
|
|
Name: "testing",
|
|
}
|
|
|
|
var tester []TestInfo
|
|
|
|
tester = append(tester, a)
|
|
tester = append(tester, a)
|
|
tester = append(tester, a)
|
|
tester = append(tester, a)
|
|
tester = append(tester, a)
|
|
tester = append(tester, a)
|
|
tester = append(tester, a)
|
|
tester = append(tester, a)
|
|
tester = append(tester, a)
|
|
tester = append(tester, a)
|
|
tester = append(tester, a)
|
|
tester = append(tester, a)
|
|
tester = append(tester, a)
|
|
tester = append(tester, a)
|
|
tester = append(tester, a)
|
|
|
|
return c.Status(200).JSON(tester)
|
|
})
|
|
|
|
port := os.Getenv("PORT")
|
|
|
|
if port == "" {
|
|
port = "3000"
|
|
}
|
|
|
|
log.Fatal(app.Listen(port))
|
|
}
|