File tree 2 files changed +30
-2
lines changed
2 files changed +30
-2
lines changed Original file line number Diff line number Diff line change @@ -363,6 +363,35 @@ The example above uses:
363
363
364
364
Note: ` WithAttrs ` and ` WithGroup ` methods of custom middleware must return a new instance, instead of ` this ` .
365
365
366
+ #### Inline handler
367
+
368
+ An "inline handler" (aka. lambda), is a shortcut to handler implement, that hooks a single method and proxies others.
369
+
370
+ ``` go
371
+ mdw := slogmulti.NewHandleInlineHandler (
372
+ // simulate "Handle()"
373
+ func (ctx context .Context , groups []string , attrs []slog .Attr , record slog .Record ) error {
374
+ // [...]
375
+ return nil
376
+ },
377
+ )
378
+ ```
379
+
380
+ ``` go
381
+ mdw := slogmulti.NewInlineHandler (
382
+ // simulate "Enabled()"
383
+ func (ctx context .Context , groups []string , attrs []slog .Attr , level slog .Level ) bool {
384
+ // [...]
385
+ return true
386
+ },
387
+ // simulate "Handle()"
388
+ func (ctx context .Context , groups []string , attrs []slog .Attr , record slog .Record ) error {
389
+ // [...]
390
+ return nil
391
+ },
392
+ )
393
+ ```
394
+
366
395
#### Inline middleware
367
396
368
397
An "inline middleware" (aka. lambda), is a shortcut to middleware implementation, that hooks a single method and proxies others.
Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORN
5
5
github.com/stretchr/objx v0.5.0 h1:1zr/of2m5FGMsad5YfcqgdqdWrIhu+EBEJRhR1U7z/c =
6
6
github.com/yuin/goldmark v1.4.13 h1:fVcFKWvrslecOb/tg+Cc05dkeYx540o0FuFt3nUVDoE =
7
7
github.com/yuin/goldmark v1.4.13 /go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY =
8
+ golang.org/x/exp v0.0.0-20220303212507-bbda1eaf7a17 /go.mod h1:lgLbSvA5ygNOMpwM/9anMpWVlVJ7Z+cHWq/eFuinpGE =
8
9
golang.org/x/mod v0.6.0 /go.mod h1:4mET923SAdbXp2ki8ey+zGs1SLqsuM2Y0uvdZR/fUNI =
9
10
golang.org/x/mod v0.11.0 h1:bUO06HqtnRcc/7l71XBe4WcqTZ+3AH1J59zWDDwLKgU =
10
11
golang.org/x/mod v0.11.0 /go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs =
@@ -18,8 +19,6 @@ golang.org/x/sys v0.1.0 h1:kunALQeHf1/185U1i0GOB/fy1IPRDDpuoOOqRReG57U=
18
19
golang.org/x/sys v0.1.0 /go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg =
19
20
golang.org/x/sys v0.20.0 /go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA =
20
21
golang.org/x/telemetry v0.0.0-20240228155512-f48c80bd79b2 /go.mod h1:TeRTkGYfJXctD9OcfyVLyj2J3IxLnKwHJR8f4D8a3YE =
21
- golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4 =
22
- golang.org/x/text v0.16.0 /go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI =
23
22
golang.org/x/tools v0.2.0 h1:G6AHpWxTMGY1KyEYoAQ5WTtIekUUvDNjan3ugu60JvE =
24
23
golang.org/x/tools v0.2.0 /go.mod h1:y4OqIKeOV/fWJetJ8bXPU1sEVniLMIyDAZWeHdV+NTA =
25
24
golang.org/x/tools v0.13.0 /go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58 =
You can’t perform that action at this time.
0 commit comments