Skip to content

Commit f19035a

Browse files
committed
Add comment to parse.go
1 parent fb618dd commit f19035a

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

linebot/webhook/parse.go

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,21 @@ var (
1616
)
1717

1818
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.
1925
SkipSignatureValidation func() bool
2026
}
2127

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.
2334
func ParseRequestWithOption(channelSecret string, r *http.Request, opt *ParseOption) (*CallbackRequest, error) {
2435
defer func() { _ = r.Body.Close() }()
2536
body, err := io.ReadAll(r.Body)
@@ -38,6 +49,10 @@ func ParseRequestWithOption(channelSecret string, r *http.Request, opt *ParseOpt
3849
return &cb, nil
3950
}
4051

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.
4156
func ParseRequest(channelSecret string, r *http.Request) (*CallbackRequest, error) {
4257
return ParseRequestWithOption(channelSecret, r, nil)
4358
}

0 commit comments

Comments
 (0)