🚚 Move api path

This commit is contained in:
LittleSheep 2024-07-16 17:01:27 +08:00
parent ee7736b261
commit 768c809cbb
6 changed files with 5 additions and 119 deletions

View File

@ -1,6 +0,0 @@
package pkg
import "embed"
//go:embed views/*
var FS embed.FS

View File

@ -4,8 +4,8 @@ import (
"github.com/gofiber/fiber/v2"
)
func MapAPIs(app *fiber.App) {
api := app.Group("/api").Name("API")
func MapAPIs(app *fiber.App, baseURL string) {
api := app.Group(baseURL).Name("API")
{
api.Get("/users/me", getUserinfo)
api.Get("/users/:accountId", getOthersInfo)

View File

@ -1,20 +1,16 @@
package server
import (
"git.solsynth.dev/hydrogen/messaging/pkg/internal"
"strings"
"git.solsynth.dev/hydrogen/messaging/pkg/internal/gap"
"git.solsynth.dev/hydrogen/messaging/pkg/internal/server/api"
"git.solsynth.dev/hydrogen/messaging/pkg/internal/server/exts"
"net/http"
"strings"
"github.com/gofiber/fiber/v2/middleware/favicon"
"github.com/gofiber/fiber/v2"
"github.com/gofiber/fiber/v2/middleware/cors"
"github.com/gofiber/fiber/v2/middleware/idempotency"
"github.com/gofiber/fiber/v2/middleware/logger"
"github.com/gofiber/template/html/v2"
jsoniter "github.com/json-iterator/go"
"github.com/rs/zerolog/log"
"github.com/spf13/viper"
@ -23,8 +19,6 @@ import (
var A *fiber.App
func NewServer() {
templates := html.NewFileSystem(http.FS(pkg.FS), ".gohtml")
A = fiber.New(fiber.Config{
DisableStartupMessage: true,
EnableIPValidation: true,
@ -35,8 +29,6 @@ func NewServer() {
JSONDecoder: jsoniter.ConfigCompatibleWithStandardLibrary.Unmarshal,
BodyLimit: 50 * 1024 * 1024,
EnablePrintRoutes: viper.GetBool("debug.print_routes"),
Views: templates,
ViewsLayout: "views/index",
})
A.Use(idempotency.New())
@ -64,19 +56,7 @@ func NewServer() {
A.Use(gap.H.AuthMiddleware)
A.Use(exts.LinkAccountMiddleware)
A.Use(favicon.New(favicon.Config{
FileSystem: http.FS(pkg.FS),
File: "views/favicon.png",
URL: "/favicon.png",
}))
api.MapAPIs(A)
A.Get("/", func(c *fiber.Ctx) error {
return c.Render("views/open", fiber.Map{
"frontend": viper.GetString("frontend"),
})
})
api.MapAPIs(A, "/")
}
func Listen() {

Binary file not shown.

Before

Width:  |  Height:  |  Size: 72 KiB

View File

@ -1,28 +0,0 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link rel="icon" type="image/png" href="favicon.png">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Roboto+Mono:ital,wght@0,100..700;1,100..700&display=swap" rel="stylesheet">
<title>Hydrogen.Interactive</title>
<style>
html, body {
padding: 0;
margin: 0;
font-family: Roboto Mono, monospace;
}
</style>
</head>
<body>
{{embed}}
</body>
</html>

View File

@ -1,60 +0,0 @@
<div class="container">
<div>
<img src="/favicon.png" width="128" height="128" alt="Icon"/>
<p class="caption text-blinking">Launching Solian... 🚀</p>
<p class="description">
Hold on a second... <br/>
We are redirecting you to our application...
</p>
</div>
</div>
<script>
function redirect() {
window.location.href = {{ .frontend }}
}
setTimeout(() => redirect(), 1850)
</script>
<style>
.container {
width: 100vw;
height: 100vh;
display: flex;
justify-content: center;
align-items: center;
text-align: center;
}
.caption {
margin-top: 4px;
font-weight: 600;
}
.text-blinking {
animation: text-blinking ease-in-out infinite 1.5s;
}
.description {
margin-top: 4px;
font-size: 0.85rem;
}
p {
margin: 0;
}
@keyframes text-blinking {
0% {
opacity: 100%;
}
50% {
opacity: 10%;
}
100% {
opacity: 100%;
}
}
</style>