routestring

package
Version: v0.13.225 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 1, 2022 License: Apache-2.0, MIT Imports: 2 Imported by: 2

Documentation

Overview

Package routestring provides a DataClient implementation for setting route configuration in form of simple eskip string.

Usage from the command line:

skipper -inline-routes '* -> inlineContent("Hello, world!") -> <shunt>'
Example
package main

import (
	"fmt"
	"io"
	"log"
	"net/http"
	"time"

	"github.com/zalando/skipper"
	"github.com/zalando/skipper/dataclients/routestring"
	"github.com/zalando/skipper/routing"
)

func main() {
	rs, err := routestring.New(`* -> inlineContent("Hello, world!") -> <shunt>`)
	if err != nil {
		log.Println(err)
		return
	}

	go func() {
		skipper.Run(skipper.Options{
			Address:           ":9999",
			CustomDataClients: []routing.DataClient{rs},
		})
	}()
	time.Sleep(1 * time.Millisecond)

	rsp, err := http.Get("http://localhost:9999")
	if err != nil {
		log.Println(err)
		return
	}

	defer rsp.Body.Close()
	content, err := io.ReadAll(rsp.Body)
	if err != nil {
		log.Println(err)
		return
	}

	fmt.Println(string(content))

}
Output:

Hello, world!

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(r string) (routing.DataClient, error)

New creates a data client that parses a string of eskip routes and serves it for the routing package.

Types

This section is empty.

Source Files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL