goprana

package module
v0.0.0-...-54a1ad8 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2015 License: BSD-3-Clause Imports: 6 Imported by: 0

README

GoPrana GoDoc

Introduction

GoPrana is a Prana client for Go.

Installation

go get github.com/jroimartin/goprana

More information

godoc -ex github.com/jroimartin/goprana

Documentation

Overview

Package goprana is a Prana client for Go.

Index

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 NewClient

func NewClient(port int) Client

NewClient returns Prana Client.

func (Client) Do

func (c Client) Do(vip, path string, req *http.Request) (resp *http.Response, err error)

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

func (c Client) DynamicProperties(ids ...string) (props map[string]string, err error)

DynamicProperties returns a map with the requested IDs and their values.

func (Client) Get

func (c Client) Get(vip, path string) (resp *http.Response, err error)

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

func (c Client) Hosts(appName, vip string) (hosts []string, err error)

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.

func (Client) Post

func (c Client) Post(vip, path, bodyType string, body io.Reader) (resp *http.Response, err error)

Post sends a POST 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.

Jump to

Keyboard shortcuts

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