personal-website/apps/websiteapp.go
2023-05-04 00:50:08 +03:00

46 lines
857 B
Go

package apps
import (
"net/http"
"github.com/gin-gonic/gin"
)
type WebDEApplication interface {
// 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())
})
}