modweb/examples/test/hello-world/main.go

46 lines
816 B
Go

package hello_world
import (
"git.ddd.rip/ptrcnull/modweb"
"github.com/gofiber/fiber/v2"
"net/http"
"os"
"path"
)
type Module struct {}
type RealFS struct {
Path string
}
func (fs RealFS) Open(filename string) (http.File, error) {
return os.Open(path.Join(fs.Path, filename))
}
func (m *Module) Init(mm *modweb.ModuleManager) {
mm.RegisterViews(RealFS{Path: "/home/patrycja/Projekty/Go/modweb/examples/test/hello-world/templates"})
app := mm.Fiber()
mm.SetHomepage("index")
app.Get("/", func(ctx *fiber.Ctx) error {
return mm.Render(ctx, "index", fiber.Map{})
})
}
func (m *Module) Name() string {
return "hello-world"
}
func (m *Module) FriendlyName() string {
return "Hello World"
}
func (m *Module) MinAccessLevel() int {
return 2136
}
func (m *Module) Hidden() bool {
return false
}