api

package
v0.14.2 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2019 License: GPL-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StatusOkay = 200

	StatusInvalidParameter    = 400
	StatusIncorrectCredential = 401
	StatusUnknownSession      = 402
	StatusPermissionDenied    = 403
	StatusDuplicated          = 404
	StatusNotFound            = 405
	StatusBlockedAccount      = 406
	StatusBlockedHost         = 407

	StatusInternalServerError = 500
	StatusServiceUnavailable  = 501
)

Variables

This section is empty.

Functions

func ResponseHandler

func ResponseHandler(f func(ResponseWriter, *rest.Request)) func(rest.ResponseWriter, *rest.Request)

Types

type Controller

type Controller interface {
	Announce(net.IP, net.HardwareAddr) error
	RemoveFlows() error
	RemoveFlowsByMAC(net.HardwareAddr) error
}

type Observer

type Observer interface {
	IsMaster() bool
}

type Response

type Response struct {
	Status  Status      `json:"status"`
	Message string      `json:"message,omitempty"` // Human readable message related with the status code.
	Data    interface{} `json:"data,omitempty"`
}

type ResponseWriter

type ResponseWriter interface {
	// Identical to the http.ResponseWriter interface
	Header() http.Header

	Write(Response)

	// Similar to the http.ResponseWriter interface, with additional JSON related
	// headers set.
	WriteHeader(int)
}

type Server

type Server struct {
	Port uint16
	TLS  struct {
		Cert string // Path for a TLS certification file.
		Key  string // Path for a TLS private key file.
	}
	Observer   Observer
	Controller Controller
}

func (*Server) Serve

func (r *Server) Serve(routes ...*rest.Route) error

type Status

type Status int

* Status Codes: * * 200 = Okay. * 4xx = Client-side errors. * 5xx = Server-side errors.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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