Documentation ¶
Overview ¶
Package listen can create a Border0 listener with configurable options. The border0 listener is a net.Listener that can be used to accept incoming connections. When the listener is passed to http.Serve, the server will accept HTTP requests sent by Border0 and forward them to an HTTP handler. The handler's response will be sent back to Border0. If no options are provided, some default values will be used.
Example:
listener := listen.New( listen.WithSocketName("sdk-socket-http"), // http socket name the listener will be bound to, socket will be created if not exists listen.WithAuthToken(os.Getenv("BORDER0_AUTH_TOKEN")), // optional, if not provided, Border0 SDK will use BORDER0_AUTH_TOKEN env var ) err := listener.Start() if err != nil { // handle error } defer listener.Close() // create a handler handler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { // do something }) // start a server using the listener http.Serve(listener, handler)
See Option for more configurable options.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Listener ¶
type Listener struct {
// contains filtered or unexported fields
}
Listener is a net.Listener that connects to a Border0 tunnel server and forwards connections to the local machine.
type Option ¶
type Option func(*Listener)
Option is a function that configures a Listener.
func WithAPIClient ¶
WithAPIClient sets the API client to use for the Listener.
func WithAuthToken ¶
WithAuthToken sets the auth token to use with the API client.
func WithSocketName ¶
WithSocketName sets the socket name to use for the HTTP socket that the Listener will create.
func WithTunnelServer ¶
WithTunnelServer sets the tunnel server address for the Listener.