Skip to content

Commit

Permalink
delete event not found handler log
Browse files Browse the repository at this point in the history
  • Loading branch information
zhaomingqiang committed Apr 26, 2021
1 parent dcf7fd0 commit 1a07620
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 10 deletions.
4 changes: 1 addition & 3 deletions event/core/handlers/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,7 @@ func complementFunc(ctx *core.Context, httpEvent *model.HTTPEvent) {
conf := config.ByCtx(ctx)
err := httpEvent.Err
if err != nil {
switch e := err.(type) {
case *NotFoundHandlerErr:
conf.GetLogger().Info(ctx, e.Error())
if _, ok := err.(*NotFoundHandlerErr); ok {
httpEvent.Response.Write(http.StatusOK, constants.DefaultContentType, fmt.Sprintf(coremodel.ResponseFormat, err.Error()))
return
}
Expand Down
5 changes: 4 additions & 1 deletion sample/event/contact.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"github.com/larksuite/oapi-sdk-go/core"
"github.com/larksuite/oapi-sdk-go/core/constants"
"github.com/larksuite/oapi-sdk-go/core/tools"
eventhttp "github.com/larksuite/oapi-sdk-go/event/http"
"github.com/larksuite/oapi-sdk-go/sample/configs"
contact "github.com/larksuite/oapi-sdk-go/service/contact/v3"
)
Expand Down Expand Up @@ -36,7 +37,9 @@ func main() {
})

g := gin.Default()
g.POST("/webhook/event", webhookEventHandle)
g.POST("/webhook/event", func(context *gin.Context) {
eventhttp.Handle(conf, context.Request, context.Writer)
})
err := g.Run(":8089")
if err != nil {
fmt.Println(err)
Expand Down
8 changes: 3 additions & 5 deletions sample/event/gin.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,11 @@ func main() {

g := gin.Default()

g.POST("/webhook/event", webhookEventHandle)
g.POST("/webhook/event", func(context *gin.Context) {
eventhttp.Handle(conf, context.Request, context.Writer)
})
err := g.Run(":8089")
if err != nil {
panic(err)
}
}

func webhookEventHandle(context *gin.Context) {
eventhttp.Handle(conf, context.Request, context.Writer)
}
5 changes: 4 additions & 1 deletion sample/event/im.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"github.com/larksuite/oapi-sdk-go/core"
"github.com/larksuite/oapi-sdk-go/core/constants"
"github.com/larksuite/oapi-sdk-go/core/tools"
eventhttp "github.com/larksuite/oapi-sdk-go/event/http"
"github.com/larksuite/oapi-sdk-go/sample/configs"
im "github.com/larksuite/oapi-sdk-go/service/im/v1"
)
Expand All @@ -24,7 +25,9 @@ func main() {
})

g := gin.Default()
g.POST("/webhook/event", webhookEventHandle)
g.POST("/webhook/event", func(context *gin.Context) {
eventhttp.Handle(conf, context.Request, context.Writer)
})
err := g.Run(":8089")
if err != nil {
fmt.Println(err)
Expand Down

0 comments on commit 1a07620

Please sign in to comment.