Tunnel
Public URLs for exposing your local web server using ngrok's API.
Installation
The only requirement is the Go Programming Language.
$ go get github.com/kataras/tunnel@latest
Getting Started
First of all, navigate to https://ngrok.com/, create an account and download ngrok. Extract the downloaded zip file anywhere you like and optionally add it to your PATH or NGROK system environment variable. Test if installation successfully completed by running the following command:
$ ngrok version
Import the package:
package main
import "github.com/kataras/tunnel"
Start a new local http Server and expose it to the internet using just a single new line of code:
func main() {
srv := &http.Server{Addr: ":8080"}
go fmt.Printf("• Public Address: %s\n", tunnel.MustStart(tunnel.WithServers(srv)))
srv.ListenAndServe()
}
OR
config := tunnel.Configuration{
Tunnels: []tunnel.Tunnel{
{Name: "my-app", Addr: ":8080"},
},
}
publicAddrs := tunnel.MustStart(config)
fmt.Printf("• Public Address: %s\n", publicAddrs)
Example output:
• Public Address: https://ef02b1377b65.ngrok.io
The Web Interface is also available.
Please navigate through _examples directory for more.
License
This software is licensed under the MIT License.