configapi

package
v0.18.4 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2021 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WriteError

func WriteError(w http.ResponseWriter, statusCode int, err error) error

WriteError writes an error response back to the ResponseWriter.

func WriteResponse

func WriteResponse(w http.ResponseWriter, statusCode int, resp interface{}) error

WriteResponse writes a response object to the provided ResponseWriter w and with a status code of statusCode. resp is marshaled to JSON.

Types

type APIResponse

type APIResponse struct {
	Status string      `json:"status"`
	Data   interface{} `json:"data,omitempty"`
}

APIResponse is the base object returned for any API call. The Data field will be set to either nil or a value of another *Response type value from this package.

func (*APIResponse) WriteTo

func (r *APIResponse) WriteTo(w http.ResponseWriter, statusCode int) error

WriteTo writes the response to the given ResponseWriter with the provided statusCode.

type ErrorResponse

type ErrorResponse struct {
	Error string `json:"error"`
}

ErrorResponse is contained inside an APIResponse and returns an error string. Returned by any API call that can fail.

type GetConfigurationResponse

type GetConfigurationResponse struct {
	// Value is the stringified YAML configuration.
	Value string `json:"value"`
}

GetConfigurationResponse is contained inside an APIResponse and provides a single configuration known to the KV store. Returned by GetConfiguration.

type ListConfigurationsResponse

type ListConfigurationsResponse struct {
	// Configs is the list of configuration names.
	Configs []string `json:"configs"`
}

ListConfigurationsResponse is contained inside an APIResponse and provides the list of configurations known to the KV store. Returned by ListConfigurations.

Jump to

Keyboard shortcuts

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