Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can this bot be used as part of an existing web app with its own routing? #5

Open
tonyalaribe opened this issue Feb 16, 2017 · 4 comments

Comments

@tonyalaribe
Copy link

I have an eccomerce platform, and would like to build a facebook bot to interact with the platform. I;m currently using julienschmidt/httprouter for routing. How can i attach the webhook to the router?

@ghost
Copy link

ghost commented Feb 18, 2017

I had to copy over SetWebhook implementation since I had only 1 http port available.

@ghost
Copy link

ghost commented Feb 18, 2017

@tonyalaribe Success in the challenge ... 😄

@tonyalaribe
Copy link
Author

Lmao... @kelonye seems i'm not the only one in the challenge. Thanks for the headsup.

@alsuren
Copy link

alsuren commented May 6, 2017

Most http frameworks seem to have a way to use a http.Handler to handle specific paths.
If you pass the mux of callbacks, mux := bot.SetWebhook("/webhook") into it, it should just work.

For my app (using gin) I had to do:

	router.GET("/webhook", gin.WrapH(mux))
	router.POST("/webhook", gin.WrapH(mux))

For julienschmidt/httprouter it looks like this method will do what you want, but I've not tried it:
https://godoc.org/github.com/julienschmidt/httprouter#Router.Handler

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants