From 892ab6406439956d0110f3e5ba97f821e2e794d2 Mon Sep 17 00:00:00 2001 From: Erika Harker Date: Thu, 18 Dec 2025 10:59:21 -0500 Subject: [PATCH 1/6] Manage message in url param --- response.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/response.go b/response.go index d6202c7..6beb36e 100644 --- a/response.go +++ b/response.go @@ -9,10 +9,13 @@ import ( "bytes" "fmt" "net/http" + "strings" ) // Response represents an HTTP response to be sent to the client, including headers, body, status code, and metadata. type Response struct { + FlashMessage string + MsgType string headers []header body []byte statusCode int @@ -144,6 +147,23 @@ func (rs *Response) Redirect(url string) *Response { }, map[string]interface{}{ "url": "url", }) + + if rs.FlashMessage != "" || rs.MsgType != "" { + if !strings.Contains(url, "?") { + url += "?" + } else { + url += "&" + } + if rs.FlashMessage != "" { + url += "flash_message=" + rs.FlashMessage + } + if rs.MsgType != "" { + if rs.FlashMessage != "" { + url += "&" + } + url += "msg_type=" + rs.MsgType + } + } if v.Failed() { if url[0:1] != "/" { rs.redirectTo = "/" + url From 9d83eed4f37290bf78b0f9645417697ef5ad1099 Mon Sep 17 00:00:00 2001 From: Erika Harker Date: Thu, 18 Dec 2025 16:50:00 -0500 Subject: [PATCH 2/6] Color Picker to form --- template/components/form_color_opacity.go | 14 +++++++++++ template/components/form_color_opacity.html | 28 +++++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 template/components/form_color_opacity.go create mode 100644 template/components/form_color_opacity.html diff --git a/template/components/form_color_opacity.go b/template/components/form_color_opacity.go new file mode 100644 index 0000000..1998386 --- /dev/null +++ b/template/components/form_color_opacity.go @@ -0,0 +1,14 @@ +package components + +type FormColorOpacity struct { + ColorID string + OpacityID string + Label string + ColorHexValue string + OpacityValue string + Hint string + Error string + IsDisabled bool + IsRequired bool + HasOpacity bool +} diff --git a/template/components/form_color_opacity.html b/template/components/form_color_opacity.html new file mode 100644 index 0000000..b429d55 --- /dev/null +++ b/template/components/form_color_opacity.html @@ -0,0 +1,28 @@ +{{ define "form_color_opacity"}} +
+ +
+ + {{if eq .HasOpacity true}} + opacity: + {{if ne .Hint ""}}{{.Hint}}{{end}} + {{if ne .Error ""}}
{{.Error}}
{{end}} + {{end}} +
+ +{{end}} + \ No newline at end of file From 3d4b3651f2227b24630cb7e97cf50f27f641d50a Mon Sep 17 00:00:00 2001 From: Erika Harker Date: Fri, 20 Mar 2026 18:21:49 -0500 Subject: [PATCH 3/6] PDF --- context.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/context.go b/context.go index 9015159..157ad4e 100644 --- a/context.go +++ b/context.go @@ -89,6 +89,22 @@ func (c *Context) GetRequesBodyMap() map[string]interface{} { return dat } +// get raw data for file binary +func (c *Context) GetRawBody() ([]byte, error) { + if c.Request.httpRequest.Body == nil { + return nil, errors.New("empty body") + } + + defer c.Request.httpRequest.Body.Close() + + data, err := io.ReadAll(c.Request.httpRequest.Body) + if err != nil { + return nil, err + } + + return data, nil +} + // get json body and bind to dest interface func (c *Context) GetRequesBodyStruct(dest interface{}) error { body := c.Request.httpRequest.Body From 1cc668a0e13de28feae42d01e84da587a852620e Mon Sep 17 00:00:00 2001 From: Erika Harker Date: Wed, 15 Apr 2026 15:17:08 -0500 Subject: [PATCH 4/6] Public request in context --- context.go | 32 +++++++++++++++++--------------- context_test.go | 4 ++-- core.go | 10 +++++----- core_test.go | 2 +- request.go | 2 +- 5 files changed, 26 insertions(+), 24 deletions(-) diff --git a/context.go b/context.go index 157ad4e..31743ca 100644 --- a/context.go +++ b/context.go @@ -56,8 +56,8 @@ func (c *Context) Next() { func (c *Context) prepare(ctx *Context) { // Only parse multipart form if it hasn't been parsed already // This prevents race conditions when multiple goroutines might access the same request - if ctx.Request.httpRequest.MultipartForm == nil { - ctx.Request.httpRequest.ParseMultipartForm(int64(app.Config.Request.MaxUploadFileSize)) + if ctx.Request.HttpRequest.MultipartForm == nil { + ctx.Request.HttpRequest.ParseMultipartForm(int64(app.Config.Request.MaxUploadFileSize)) } } @@ -66,38 +66,40 @@ func (c *Context) GetPathParam(key string) interface{} { } func (c *Context) GetRequestParam(key string) interface{} { - return c.Request.httpRequest.FormValue(key) + return c.Request.HttpRequest.FormValue(key) } func (c *Context) RequestParamExists(key string) bool { - return c.Request.httpRequest.Form.Has(key) + return c.Request.HttpRequest.Form.Has(key) } func (c *Context) GetRequesForm(key string) interface{} { - c.Request.httpRequest.ParseForm() - return c.Request.httpRequest.Form[key] + c.Request.HttpRequest.ParseForm() + return c.Request.HttpRequest.Form[key] } func (c *Context) GetRequesBodyMap() map[string]interface{} { var dat map[string]any - body := c.Request.httpRequest.Body + body := c.Request.HttpRequest.Body + if body != nil { if content, err := io.ReadAll(body); err == nil { json.Unmarshal(content, &dat) } } + defer body.Close() return dat } // get raw data for file binary func (c *Context) GetRawBody() ([]byte, error) { - if c.Request.httpRequest.Body == nil { + if c.Request.HttpRequest.Body == nil { return nil, errors.New("empty body") } - defer c.Request.httpRequest.Body.Close() + defer c.Request.HttpRequest.Body.Close() - data, err := io.ReadAll(c.Request.httpRequest.Body) + data, err := io.ReadAll(c.Request.HttpRequest.Body) if err != nil { return nil, err } @@ -107,7 +109,7 @@ func (c *Context) GetRawBody() ([]byte, error) { // get json body and bind to dest interface func (c *Context) GetRequesBodyStruct(dest interface{}) error { - body := c.Request.httpRequest.Body + body := c.Request.HttpRequest.Body if body != nil { value := reflect.ValueOf(dest) if value.Kind() != reflect.Ptr { @@ -121,12 +123,12 @@ func (c *Context) GetRequesBodyStruct(dest interface{}) error { } func (c *Context) GetHeader(key string) string { - return c.Request.httpRequest.Header.Get(key) + return c.Request.HttpRequest.Header.Get(key) } func (c *Context) GetCookie() (UserCookie, error) { - user, err := GetCookie(c.Request.httpRequest) + user, err := GetCookie(c.Request.HttpRequest) if err != nil { return user, err } @@ -142,7 +144,7 @@ func (c *Context) GetQueueClient() *asynq.Client { } func (c *Context) GetUploadedFile(name string) (*UploadedFileInfo, error) { - file, fileHeader, err := c.Request.httpRequest.FormFile(name) + file, fileHeader, err := c.Request.HttpRequest.FormFile(name) if err != nil { return nil, fmt.Errorf("error retrieving file: %v", err) } @@ -306,7 +308,7 @@ func (c *Context) CastToString(value interface{}) string { } func (c Context) GetUserAgent() string { - return c.Request.httpRequest.UserAgent() + return c.Request.HttpRequest.UserAgent() } func (c *Context) CastToInt(value interface{}) int { diff --git a/context_test.go b/context_test.go index 9cc4287..d812454 100644 --- a/context_test.go +++ b/context_test.go @@ -25,7 +25,7 @@ func TestDebugAny(t *testing.T) { w := httptest.NewRecorder() c := &Context{ Request: &Request{ - httpRequest: r, + HttpRequest: r, httpPathParams: nil, }, Response: &Response{ @@ -538,7 +538,7 @@ func makeCTXLogTestCTX(t *testing.T, w http.ResponseWriter, r *http.Request, tmp t.Helper() return &Context{ Request: &Request{ - httpRequest: r, + HttpRequest: r, httpPathParams: nil, }, Response: &Response{ diff --git a/core.go b/core.go index 9afef81..8e7e4f1 100644 --- a/core.go +++ b/core.go @@ -242,7 +242,7 @@ func (app *App) makeHTTPRouterHandlerFunc(h Controller, ms []Hook) httprouter.Ha reqCtx := &requestContext{ chainIndex: 0, } - + // Prepare the chain nodes for this request mw := app.hooks.GetHooks() for _, v := range mw { @@ -252,11 +252,11 @@ func (app *App) makeHTTPRouterHandlerFunc(h Controller, ms []Hook) httprouter.Ha for _, v := range rhs { reqCtx.chainNodes = append(reqCtx.chainNodes, v) } - + // Store chain state in request context ctx := &Context{ Request: &Request{ - httpRequest: r.WithContext(context.WithValue(r.Context(), "goffeeChain", reqCtx)), + HttpRequest: r.WithContext(context.WithValue(r.Context(), "goffeeChain", reqCtx)), httpPathParams: ps, }, Response: &Response{ @@ -279,7 +279,7 @@ func (app *App) makeHTTPRouterHandlerFunc(h Controller, ms []Hook) httprouter.Ha } ctx.prepare(ctx) - + // Execute the first handler in the chain if len(reqCtx.chainNodes) > 0 { n := reqCtx.chainNodes[0] @@ -392,7 +392,7 @@ func UseHook(mw Hook) { // Next advances to the next middleware or controller in the chain and invokes it with the given context if available. func (app *App) Next(c *Context) { // Get request-specific chain state from context - if reqCtx, ok := c.Request.httpRequest.Context().Value("goffeeChain").(*requestContext); ok { + if reqCtx, ok := c.Request.HttpRequest.Context().Value("goffeeChain").(*requestContext); ok { reqCtx.chainIndex++ if reqCtx.chainIndex < len(reqCtx.chainNodes) { n := reqCtx.chainNodes[reqCtx.chainIndex] diff --git a/core_test.go b/core_test.go index fc146af..b76faaf 100644 --- a/core_test.go +++ b/core_test.go @@ -226,7 +226,7 @@ func makeCTX(t *testing.T) *Context { t.Helper() return &Context{ Request: &Request{ - httpRequest: httptest.NewRequest(GET, LOCALHOST, nil), + HttpRequest: httptest.NewRequest(GET, LOCALHOST, nil), httpPathParams: nil, }, Response: &Response{ diff --git a/request.go b/request.go index a93ac62..008b3e5 100644 --- a/request.go +++ b/request.go @@ -12,6 +12,6 @@ import ( ) type Request struct { - httpRequest *http.Request + HttpRequest *http.Request httpPathParams httprouter.Params } From 69c962f50697c83da550166fbbec1615710cc7a4 Mon Sep 17 00:00:00 2001 From: Erika Harker Date: Wed, 15 Apr 2026 16:14:06 -0500 Subject: [PATCH 5/6] change name module in go.mod --- go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 9a967b5..6e8c01f 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module git.smarteching.com/goffee/core +module git.smarteching.com/ErikaHarker/core replace git.smarteching.com/goffee/core/logger => ./logger From cfe5d555a487da8fdff5906488e49c00ecf8134c Mon Sep 17 00:00:00 2001 From: ErikaHarker Date: Wed, 15 Apr 2026 17:20:30 -0400 Subject: [PATCH 6/6] revert 69c962f50697c83da550166fbbec1615710cc7a4 revert change name module in go.mod --- go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 6e8c01f..9a967b5 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module git.smarteching.com/ErikaHarker/core +module git.smarteching.com/goffee/core replace git.smarteching.com/goffee/core/logger => ./logger