lijian 87463c0f07 update vendor 1 rok pred
..
.gitignore 87463c0f07 update vendor 1 rok pred
.travis.yml 87463c0f07 update vendor 1 rok pred
CODE_OF_CONDUCT.md 87463c0f07 update vendor 1 rok pred
CONTRIBUTING.md 87463c0f07 update vendor 1 rok pred
LICENSE 87463c0f07 update vendor 1 rok pred
README.md 87463c0f07 update vendor 1 rok pred
configuration.go 48c2e0e9f9 依赖更新为 go mod 1 rok pred
tunnel.go 48c2e0e9f9 依赖更新为 go mod 1 rok pred

README.md

Tunnel

build status report card godocs

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() {
    // [...http.HandleFunc]

    srv := &http.Server{Addr: ":8080"}
    // 1 LOC:
    go fmt.Printf("• Public Address: %s\n", tunnel.MustStart(tunnel.WithServers(srv)))
    //
    srv.ListenAndServe()
}

OR

config := tunnel.Configuration{
    // AuthToken: "<YOUR_AUTHTOKEN>",
    // Bin: "C:/ngrok.exe",
    // WebInterface: "http://127.0.0.1:4040",
    // Region: "eu",
    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.