@@ -16,10 +16,21 @@ var (
16
16
)
17
17
18
18
type ParseOption struct {
19
+ // SkipSignatureValidation is a function that determines whether to skip
20
+ // webhook signature verification.
21
+ //
22
+ // If the function returns true, the signature verification step is skipped.
23
+ // This can be useful in scenarios such as when you're in the process of updating
24
+ // the channel secret and need to temporarily bypass verification to avoid disruptions.
19
25
SkipSignatureValidation func () bool
20
26
}
21
27
22
- // ParseRequest func
28
+ // ParseRequestWithOption parses a LINE webhook request with optional behavior.
29
+ //
30
+ // Use this when you need to customize parsing, such as skipping signature validation
31
+ // via ParseOption. This is useful during channel secret rotation or local development.
32
+ //
33
+ // For standard use, prefer ParseRequest.
23
34
func ParseRequestWithOption (channelSecret string , r * http.Request , opt * ParseOption ) (* CallbackRequest , error ) {
24
35
defer func () { _ = r .Body .Close () }()
25
36
body , err := io .ReadAll (r .Body )
@@ -38,6 +49,10 @@ func ParseRequestWithOption(channelSecret string, r *http.Request, opt *ParseOpt
38
49
return & cb , nil
39
50
}
40
51
52
+ // ParseRequest parses a LINE webhook request with signature verification.
53
+ //
54
+ // If you need to customize behavior (e.g. skip signature verification),
55
+ // use ParseRequestWithOption instead.
41
56
func ParseRequest (channelSecret string , r * http.Request ) (* CallbackRequest , error ) {
42
57
return ParseRequestWithOption (channelSecret , r , nil )
43
58
}
0 commit comments