Skip to content

Commit

Permalink
docs: fix wrong examples [ci skip]
Browse files Browse the repository at this point in the history
  • Loading branch information
crispgm committed Jan 4, 2024
1 parent 7eb9ca3 commit 5424367
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func main() {
{
eventGroup.Use(middleware.LarkEventHandler())
eventGroup.POST("/", func(c context.Context, ctx *app.RequestContext) {
if event, ok := middleware.GetEvent(e); ok { // => returns `*lark.EventV2`
if event, ok := middleware.GetEvent(ctx); ok { // => returns `*lark.EventV2`
}
})
}
Expand All @@ -54,7 +54,7 @@ func main() {
{
cardGroup.Use(middleware.LarkCardHandler())
cardGroup.POST("/callback", func(c context.Context, ctx *app.RequestContext) {
if card, ok := middleware.GetCardCallback(c); ok { // => returns `*lark.EventCardCallback`
if card, ok := middleware.GetCardCallback(ctx); ok { // => returns `*lark.EventCardCallback`
}
})
}
Expand All @@ -75,8 +75,7 @@ r.Use(middleware.LarkEventHandler())
Get the event (e.g. Message):
```go
r.POST("/", func(c context.Context, ctx *app.RequestContext) {
event, ok = middleware.GetEvent(ctx)
if evt, ok := middleware.GetEvent(c); ok { // => GetEvent instead of GetMessage
if event, ok := middleware.GetEvent(ctx); ok { // => GetEvent instead of GetMessage
if evt.Header.EventType == lark.EventTypeMessageReceived {
if msg, err := evt.GetMessageReceived(); err == nil {
fmt.Println(msg.Message.Content)
Expand Down

0 comments on commit 5424367

Please sign in to comment.