Commit graph

50 commits

Author SHA1 Message Date
wjqserver
e7c7d5e41f fix: 修复 Client() 返回过时 HTTPClient 的问题
- 将 Client() 从返回 c.HTTPClient 改为返回 c.engine.HTTPClient
- 与 HTTPC() 方法保持一致
2026-04-22 07:30:40 +08:00
wjqserver
f2295c3084 feat: httpc 集成改进,自动关联请求 Context
- 新增 contextHTTPClient 包装器,自动关联请求 Context
- 新增 Context.HTTPC() 方法返回 contextHTTPClient
- Client() 标记为 Deprecated
- 添加 GetHTTPC() go:fix inline 兼容函数

当请求被取消时,出站 HTTP 请求也会自动取消。
2026-04-21 22:55:26 +08:00
wjqserver
c8b14ef43a feat: 引入 Logger 接口抽象,支持自定义日志实现
- 新增 Logger 接口定义,支持 zap/slog 等自定义实现
- 新增 CloserLogger 接口用于支持关闭操作
- Engine 新增 SetLogger/GetLogger 方法使用接口
- 新增 compat.go 兼容层,保留 reco 兼容方法
- 新增 slog 适配器示例
- 删除 zap 示例
- Context.GetLogger() 返回接口类型
2026-04-21 19:43:56 +08:00
wjqserver
54f7de0c60 perf: modernize io paths and reduce proxy allocations 2026-04-11 01:43:34 +08:00
wjqserver
2d4aefc86e fix: cut redirect and allow-path routing overhead
Reuse fixed-path and Allow-header buffers so redirect and OPTIONS handling stop rebuilding temporary data on every request. Cache fallback chains and add regression coverage for redirect, 404, 405, and Allow behavior to keep the faster miss paths stable.
2026-04-07 09:06:56 +08:00
wjqserver
5d979e5670 fix: reduce per-request context and fallback overhead
Make Context keys lazy so requests that never call Set stop allocating on reset. Reuse stable 404 and 405 handlers and add focused benchmarks so ServeHTTP miss paths stay measurable.
2026-04-07 08:39:10 +08:00
wjqserver
85cc9b5cf6 fix(form): align PostForm parsing with body limit handling 2026-03-31 18:59:32 +08:00
wjqserver
64e2ad9e7b Fix FileText status code and unify request body size limits
- FileText: now respects the provided status code instead of defaulting to 200 OK
- Request body limits: prepareRequestBody() is now only called when MaxRequestBodySize > 0
  - ShouldBindJSON, ShouldBindWANF, ShouldBindGOB, ShouldBindForm, GetReqBody, PostForm
    all now use the original c.Request.Body path when no limit is configured
- maxBytesReader: fixed exact-limit boundary case where body size == limit was
  incorrectly rejected
- Added regression tests for FileText status codes and body limit behavior

All existing tests pass, and new tests verify the corrected behavior.
2026-03-31 16:38:04 +08:00
wjqserver
9f210deadf fix(cookie): add warning log when multiple SameSite values provided 2026-03-30 01:42:10 +08:00
wjqserver
7be49b96c8 feat(cookie): add SameSite support to SetCookie method 2026-03-30 01:33:00 +08:00
WJQSERVER
fba6fedfc5
Update context.go
Some checks failed
Go Test / test (push) Has been cancelled
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
2026-03-30 01:17:59 +08:00
WJQSERVER
d0fa14c3c5
Update context.go
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
2026-03-30 01:17:32 +08:00
wjqserver
45c6d36748 fix(HTMLBuf): return 500 on template error, no content
- Remove fallback to HTML() on template rendering failure
- Return 500 error without writing any content on error
- Only fallback to HTML() when renderer is nil or unsupported type
- Prevents multiple response writes
2026-03-30 01:02:37 +08:00
wjqserver
b4e45610b2 refactor(HTMLBuf): delegate fallback to HTML() method
Reduce code duplication by calling c.HTML() for fallback cases:
- When template rendering fails
- When HTMLRender is not configured
- When HTMLRender is not a *template.Template

This ensures consistent behavior between HTMLBuf and HTML methods.
2026-03-30 00:29:50 +08:00
wjqserver
b09595e745 fix: address PR #73 review feedback
- Remove redundant c.Errorf call in JSONBuf
- Consolidate error wrapping in HTMLBuf to avoid duplicate fmt.Errorf calls
- Keep error handling consistent across all Buf methods
2026-03-29 23:43:29 +08:00
wjqserver
6e33bc48aa fix: simplify error handling in Buf methods
Consolidate error wrapping to avoid redundant fmt.Errorf calls.
Follows PR #73 review feedback.
2026-03-29 18:45:08 +08:00
wjqserver
7e15181c0b feat(render): add Buf variants for JSON/GOB/WANF/HTML
Add buffered rendering methods that encode to a buffer first, then
write the response. This allows returning a proper 500 status code
if encoding fails, unlike the streaming variants which must write
the status code before encoding (an inherent HTTP constraint).

New methods:
- JSONBuf(code int, obj any)
- GOBBuf(code int, obj any)
- WANFBuf(code int, obj any)
- HTMLBuf(code int, name string, obj any)

Trade-off: one extra memory allocation per call in exchange for
correct error status codes on encoding failure.
2026-03-29 17:03:57 +08:00
WJQSERVER
c4c0160b5f refactor: improve binding, performance, and type safety
- Implement ShouldBind with support for JSON, Form, WANF, and GOB formats
- Add ShouldBindForm, ShouldBindGOB, and helper functions for form binding
- Use fmt.Appendf instead of fmt.Sprintf for better performance
- Replace interface{} with any for modern Go style
- Use maps.Copy for cleaner header copying
- Update strings.SplitSeq to use range over strings.Seq
- Remove deprecated placeholder comments and add proper implementations
- Fix reflect.Pointer usage for Go 1.22+ compatibility
2026-03-17 12:02:49 +08:00
WJQSERVER
a6e278d458 print errlog (jsonv2 marshal) 2026-01-26 08:08:01 +08:00
WJQSERVER
60b2936eff add TempSkippedNodesPool 2025-12-14 23:16:29 +08:00
WJQSERVER
904aea5df8 refactor: Improve engine's tree processing and context handling. 2025-12-14 22:56:37 +08:00
wjqserver
e4aaaa1583 fix path to filepath 2025-10-21 15:06:26 +08:00
wjqserver
1361f6e237 update 2025-10-21 14:47:29 +08:00
wjqserver
3ffde5742c add wanf 2025-08-20 16:50:26 +08:00
wjqserver
3590a77f90 fix reqip val 2025-08-01 10:23:49 +08:00
wjqserver
295852e1a1 update reqip 2025-08-01 09:05:09 +08:00
google-labs-jules[bot]
504089b748 feat: add MPL 2.0 license headers to all go files 2025-07-24 08:07:38 +00:00
wjqserver
6b3f3335ab replace to iox 2025-07-18 17:40:01 +08:00
wjqserver
ad167b6646 add Text 2025-07-18 15:26:43 +08:00
wjqserver
49508b49c1 fix limitMaxSizeReader non use body close & fix mergeCtx Value 2025-07-09 00:17:52 +08:00
wjqserver
cb86cb935a add maxBytesReader & ctxMerge 2025-07-08 13:26:18 +08:00
wjqserver
17bab2dcfd remove unuse code 2025-07-06 18:09:37 +08:00
wjqserver
edca87906d update deps & use copyb high perfromance pool & switch to stream json encoder 2025-07-06 17:59:24 +08:00
wjqserver
76d07364ae optimize defaulterrorhandle && add SetRespBodyFile 2025-06-25 17:49:03 +08:00
wjqserver
53544644af use new resolveRoutePath replace path.Join && add UseIf 2025-06-17 14:20:14 +08:00
wjqserver
bfc6b439e4 [context] add SetHeaders 2025-06-14 17:58:08 +08:00
wjqserver
896182417f fix header writer after status issue 2025-06-11 11:24:54 +08:00
wjqserver
bb822599b9 update methods 2025-06-11 11:11:54 +08:00
wjqserver
ce5efae287 update 2025-06-10 21:37:53 +08:00
wjqserver
e6b54eedbf remove tgzip 2025-06-10 00:04:15 +08:00
wjqserver
1d5ffac153 [context] optimize context reset and reuse 2025-06-06 22:40:40 +08:00
wjqserver
61e67bc2a0 [context] fix writer reset 2025-06-06 21:29:09 +08:00
wjqserver
757cd962ab [context] Add Cookie Method, port from gin 2025-06-05 18:35:28 +08:00
wjqserver
b8a1c5523a ctx add logreco method 2025-06-04 21:30:56 +08:00
wjqserver
899d3ff48b add logreco 2025-06-04 20:44:23 +08:00
wjqserver
385b6239c8 add GetHTTPC 2025-06-04 18:40:00 +08:00
wjqserver
6eac3b2046 add GetProtocol 2025-06-02 02:10:25 +08:00
wjqserver
8ae88a77f0 add Raw & GetReqBodyFull 2025-05-30 16:51:38 +08:00
wjqserver
5a10829041 add ErrorUseHandle 2025-05-28 21:34:08 +08:00
wjqserver
484f2f016b init(v0.0.1) 2025-05-28 18:25:28 +08:00