Documentation ¶
Overview ¶
Package border0 provides helper functions to:
- create a Border API client to manage Border0 resources
- create a Border listener to handle incoming HTTP connections
About Border0 ¶
Border0 enables users to log into various services, including web, SSH, database, and generic TCP, using their existing Single Sign-On (SSO) credentials. If you haven't yet registered, create a new account and explore our informative blog posts and comprehensive documentation.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Listen ¶
Listen creates a new Border0 listener with the given options. It returns 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 the handler. The handler's response will be sent back to Border0. If no options are provided, some default values will be used. See the listen.Option type for more details.
Explore examples folder for additional examples of how to use this Listen function with other HTTP libraries and frameworks.
Example ¶
listener, err := border0.Listen( 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 ) if err != nil { log.Fatalln("failed to start listener:", err) } handler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { name := r.Header.Get("X-Auth-Name") // border0 will set this header along with a few other identity related headers fmt.Fprintf(w, "Hello, %s! This is border0-go + standard library http.", name) }) log.Fatalln(http.Serve(listener, handler))
Output:
func NewAPIClient ¶
NewAPIClient creates a new Border0 API client with the given options. If no options are provided, some default values will be used. See the client.Option type for more details.
Explore examples folder for additional examples of how to manage Border0 resources using this API client.
Example ¶
api := border0.NewAPIClient( client.WithAuthToken(os.Getenv("BORDER0_AUTH_TOKEN")), // optional, if not provided, Border0 SDK will use BORDER0_AUTH_TOKEN env var client.WithRetryMax(2), // 1 initial + 2 retries = 3 attempts ) ctx := context.Background() // create socket socket := client.Socket{ Name: "sdk-socket-http", SocketType: "http", } created, err := api.CreateSocket(ctx, &socket) if err != nil { log.Fatalln("failed to create socket using border0 api client sdk:", err) } log.Printf("created socket: %+v", created)
Output:
Types ¶
This section is empty.
Directories ¶
Path | Synopsis |
---|---|
Package client provides API client methods that interact with our API to manage Border0 resources.
|
Package client provides API client methods that interact with our API to manage Border0 resources. |
examples
module
|
|
lib
|
|
Package listen can create a Border0 listener with configurable options.
|
Package listen can create a Border0 listener with configurable options. |
types
|
|