Documentation ¶
Overview ¶
Package obsidian provides common types and constants for implementors of REST API handlers.
Index ¶
- Constants
- Variables
- func AttachAll(e *echo.Echo, m ...echo.MiddlewareFunc)
- func AttachHandlers(e *echo.Echo, handlers []Handler, m ...echo.MiddlewareFunc)
- func CheckNetworkAccess(c echo.Context, networkId string) *echo.HTTPError
- func CheckTenantAccess(c echo.Context) *echo.HTTPError
- func CheckWildcardNetworkAccess(c echo.Context) *echo.HTTPError
- func GetNetworkAndGatewayIDs(c echo.Context) (string, string, *echo.HTTPError)
- func GetNetworkId(c echo.Context) (string, *echo.HTTPError)
- func GetOperatorId(c echo.Context) (string, *echo.HTTPError)
- func GetParamValues(c echo.Context, paramNames ...string) ([]string, *echo.HTTPError)
- func GetTenantID(c echo.Context) (int64, *echo.HTTPError)
- func HttpError(err error, code ...int) *echo.HTTPError
- func NetworkIdHttpErr() *echo.HTTPError
- func Register(handler Handler) error
- func RegisterAll(handlers []Handler) error
- func TenantIdHttpErr() *echo.HTTPError
- func Unregister(path string, methods HttpMethod)
- type Handler
- type HttpMethod
Constants ¶
const ( Product = "Obsidian Server" Version = "0.1" DefaultPort = 9081 DefaultHttpsPort = 9443 DefaultServerCert = "server_cert.pem" DefaultServerCertKey = "server_cert.key.pem" DefaultClientCAs = "ca_cert.pem" DefaultStaticFolder = "/var/opt/magma/static" StaticURLPrefix = "/apidocs" ServiceName = "OBSIDIAN" )
const ( UrlSep = "/" MagmaNetworksUrlPart = "networks" MagmaOperatorsUrlPart = "operators" // "/magma" RestRoot = UrlSep + "magma" // "/magma/networks" NetworksRoot = RestRoot + UrlSep + MagmaNetworksUrlPart // "/magma/operators" OperatorsRoot = RestRoot + UrlSep + MagmaOperatorsUrlPart // Supported API versions V0 = "" V1 = "v1" // Note the trailing slash (this is actually important for apidocs to render properly) V1Root = RestRoot + UrlSep + V1 + UrlSep )
Variables ¶
var ( TLS bool Port int ServerCertPemPath string ServerKeyPemPath string ClientCAPoolPath string AllowAnyClientCert bool StaticFolder string )
configs
Functions ¶
func AttachAll ¶
func AttachAll(e *echo.Echo, m ...echo.MiddlewareFunc)
AttachAll activates all registered (see: Register above) handlers Main package should call AttachAll after all handlers were registered
func AttachHandlers ¶
func AttachHandlers(e *echo.Echo, handlers []Handler, m ...echo.MiddlewareFunc)
AttachHandlers attaches the provided obsidian handlers to the echo server
func CheckTenantAccess ¶
CheckTenantAccess checks that the context has network wildcard access i.e. is admin
func GetNetworkAndGatewayIDs ¶
func GetParamValues ¶
GetParamValues returns a list of the value for each param provided in `paramNames`. Returns a status bad request HTTP error if any param value is blank.
func NetworkIdHttpErr ¶
func Register ¶
Register registers a given handler for given path and HTTP methods Note: the handlers won't become active until they are 'attached' to the echo server, see AttachAll below
func RegisterAll ¶
RegisterAll registers an array of Handlers. If an error is encountered while registering any handler, RegisterAll will exit early with that error and rollback any handlers which were already registered.
func TenantIdHttpErr ¶
func Unregister ¶
func Unregister(path string, methods HttpMethod)
Unregister unregisters the handler for the specified path and HttpMethod if it is registered. No action will be taken if no such handler is registered.
Types ¶
type Handler ¶
type Handler struct { Path string // Methods is a bitmask so one Handler can support multiple http methods. // See consts defined below. Methods HttpMethod HandlerFunc echo.HandlerFunc }
Handler wraps a function which serves a specified path and http method.
type HttpMethod ¶
type HttpMethod byte