Documentation ¶
Overview ¶
Package goprana is a Prana client for Go.
Index ¶
- Constants
- type Client
- func (c Client) Do(vip, path string, req *http.Request) (resp *http.Response, err error)
- func (c Client) DynamicProperties(ids ...string) (props map[string]string, err error)
- func (c Client) Get(vip, path string) (resp *http.Response, err error)
- func (c Client) Hosts(appName, vip string) (hosts []string, err error)
- func (c Client) Post(vip, path, bodyType string, body io.Reader) (resp *http.Response, err error)
Examples ¶
Constants ¶
View Source
const DefaultPort = 8078
DefaultPort is default Prana port.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct { // FollowRedirects allows to specify if the client should follow redirects. FollowRedirects bool // contains filtered or unexported fields }
A Client represents a Prana client.
func (Client) Do ¶
Do sends a request to the specified VIP and path via Ribbon. Caller should close resp.Body when done reading from it. If the provided body is an io.Closer, it is closed after the request.
func (Client) DynamicProperties ¶
DynamicProperties returns a map with the requested IDs and their values.
func (Client) Get ¶
Get sends a GET request to the specified VIP and path via Ribbon.
Example ¶
package main import ( "io/ioutil" "log" "github.com/jroimartin/goprana" ) func main() { c := goprana.NewClient(goprana.DefaultPort) resp, err := c.Get("gotquotes-go", "/api/quote/random") if err != nil { log.Fatalln(err) } defer resp.Body.Close() output, err := ioutil.ReadAll(resp.Body) if err != nil { log.Fatalln(err) } log.Printf("%s", output) }
Output:
func (Client) Hosts ¶
Hosts returns a list of hosts which are marked as UP in Eureka for the specific application and VIP passed as query parameters. If a VIP name is passed we filter the hosts matching that VIP name.
Click to show internal directories.
Click to hide internal directories.