personal-website/websiteapp/websiteapp.go

46 lines
863 B
Go

package websiteapp
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())
})
}