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

Request: Documentation on How to use ngrok with Gin and Echo frameworks #81

Closed
aphsa opened this issue Mar 18, 2023 · 1 comment
Closed

Comments

@aphsa
Copy link

aphsa commented Mar 18, 2023

Documentation on How to integrate ngrok with Gin and Echo frameworks would be helpful.

@aphsa
Copy link
Author

aphsa commented Mar 18, 2023

I guess this will do for gin.

func run(ctx context.Context) error {
        l, err := ngrok.Listen(ctx,
                config.HTTPEndpoint(),
                ngrok.WithAuthtokenFromEnv(),
        )
        if err != nil {
                return err
        }
        fmt.Println("Listening at ", l.Addr())
        handler := gin.New()
        handler.GET("/ping", func(c *gin.Context) {
                c.JSON(http.StatusOK, gin.H{
                        "message": "Pong",
                })
        })
        return http.Serve(l, handler)
}

@aphsa aphsa closed this as completed Mar 18, 2023
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

1 participant