forked from mbk-lab/rui_orig
2
0
Fork 0

описание

This commit is contained in:
Роман Бородин 2024-04-12 17:06:55 +03:00
parent d4831bb68d
commit d8ab76da20
1 changed files with 19 additions and 0 deletions

View File

@ -20,6 +20,25 @@ func (h *httpHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
} }
} }
/*
NewHandler используется для встраивания приложения rui в сторонние WEB-фреймворки (net/http, gin, echo...).
Пример для echo:
e := echo.New()
e.Any(`/ui/*`, func()echo.HandlerFunc{
rui.AddEmbedResources(&resources)
h := rui.NewHandler("/ui", CreateSessionContent, rui.AppParams{
Title: `Awesome app`,
Icon: `favicon.png`,
})
return func(c echo.Context) error {
h.ServeHTTP(c.Response(), c.Request())
return nil
}
})
*/
func NewHandler(urlPrefix string, createContentFunc func(Session) SessionContent, params AppParams) *httpHandler { func NewHandler(urlPrefix string, createContentFunc func(Session) SessionContent, params AppParams) *httpHandler {
app := new(application) app := new(application)
app.params = params app.params = params