personal-website/apps/websiteapp.go

46 lines
857 B
Go
Raw Normal View History

2023-05-03 21:50:08 +00:00
package apps
2023-03-15 12:34:03 +00:00
2023-03-17 01:16:51 +00:00
import (
"net/http"
"github.com/gin-gonic/gin"
)
2023-03-15 12:34:03 +00:00
type WebDEApplication interface {
2023-03-17 01:16:51 +00:00
// Render()
GetManifest() ApplicationManifest
// GEtHtml()
GetId() string
}
type ApplicationManifest struct {
AppId string `json:"appid"`
WindowName string `json:"windowname"`
}
type ApplicationsStorage struct {
Apps map[string]WebDEApplication
}
// func NewApplicationsStorage() *ApplicationsStorage {
// newStorage := ApplicationsStorage{}
// return &newStorage
// }
func Route(route *gin.RouterGroup, aStorage *ApplicationsStorage) {
route.GET("/get", func(ctx *gin.Context) {
appId := ctx.Query("appid")
if appId == "" {
ctx.Status(http.StatusBadRequest)
return
}
app, isExist := aStorage.Apps[appId]
if !isExist {
ctx.Status(http.StatusNoContent)
return
}
ctx.JSON(http.StatusOK, app.GetManifest())
})
2023-03-15 12:34:03 +00:00
}