ctlapi

package
v0.0.0-...-0178fca Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2018 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ServiceURI is uri prefix for service resources.
	ServiceURI = "services"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type APIClient

type APIClient struct {
	// contains filtered or unexported fields
}

APIClient is client for ctlapi.

func NewClient

func NewClient(endpoint string, timeout time.Duration) (*APIClient, error)

NewClient returns a new ApiClient.

func (*APIClient) Delete

func (client *APIClient) Delete(url string) (int, []byte, error)

Delete requests a DELETE method.

func (*APIClient) Get

func (client *APIClient) Get(url string) (int, []byte, error)

Get requests a PUT method.

func (*APIClient) GetService

func (client *APIClient) GetService(name string) (resp model.IdempotentServiceParam, status int, err error)

GetService calls GET service.

func (*APIClient) Post

func (client *APIClient) Post(url string, body interface{}) (int, []byte, error)

Post requests a POST method.

func (*APIClient) PostService

func (client *APIClient) PostService(name string, req PostServiceReq) (service model.Service, status int, err error)

PostService calls POST service.

func (*APIClient) Put

func (client *APIClient) Put(url string, body interface{}) (int, []byte, error)

Put requests a PUT method.

func (*APIClient) PutService

func (client *APIClient) PutService(name string, req model.IdempotentServiceParam) (resp PutServiceResp, status int, err error)

PutService calls PUT service.

type APIHandler

type APIHandler func(w http.ResponseWriter, r *http.Request, param httprouter.Params, body []byte)

APIHandler is common HTTP handler type.

type PostServiceReq

type PostServiceReq struct {
	Protocol string `json:"protocol"`
}

PostServiceReq is the request type of POST service method.

type PutServiceResp

type PutServiceResp struct {
	Changed bool `json:"changed"`
}

PutServiceResp is theresponse type of PUT service method.

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server is a API server.

func NewServer

func NewServer(inventory core.InventoryService, conf model.CtlAPIConf, logger *logrus.Logger) *Server

NewServer creates a new API server.

func (*Server) Run

func (srv *Server) Run() error

Run run

func (*Server) ServeHTTP

func (srv *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)

Jump to

Keyboard shortcuts

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