From d8ab76da206ed6eeb2608f2cc8f7214eb418baf2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A0=D0=BE=D0=BC=D0=B0=D0=BD=20=D0=91=D0=BE=D1=80=D0=BE?= =?UTF-8?q?=D0=B4=D0=B8=D0=BD?= Date: Fri, 12 Apr 2024 17:06:55 +0300 Subject: [PATCH] =?UTF-8?q?=D0=BE=D0=BF=D0=B8=D1=81=D0=B0=D0=BD=D0=B8?= =?UTF-8?q?=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- http_handler.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/http_handler.go b/http_handler.go index 706dd8c..321bbfb 100644 --- a/http_handler.go +++ b/http_handler.go @@ -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 { app := new(application) app.params = params