api

package
v2.0.36 Latest Latest
Warning

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

Go to latest
Published: May 26, 2020 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package api provides common api functionality

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register added in v2.0.36

func Register(name string, iface NewFunc)

Register registers a new api interface

Types

type Authorizer

type Authorizer interface {
	// AuthBasic handles basic authentication
	AuthBasic(user string, pass string) (interface{}, error)

	// AuthToken handles simple token or api key authentication
	AuthToken(token string) (interface{}, error)

	// AuthOauth handles Oauth 2.0 token authorization
	AuthOauth(token string, scopes []string) (interface{}, error)
}

Authorizer is an api authorization interface

type Controller

type Controller interface {
	// DB returns the application database instance
	DB() *sql.DB

	// Options returns the application config kvdb
	Options() jsondb.DB

	// Authorizer returns the application api authorizer
	Authorizer() Authorizer
}

Controller provided basic functions to an api

type Interface added in v2.0.34

type Interface interface {
	// Handler returns the http handler for the api
	Handler() http.Handler

	// Name returns the api name
	Name() string
}

Interface is the common api interface

func Create added in v2.0.36

func Create(name string, c Controller) (Interface, error)

Create a new api interface

type NewFunc added in v2.0.36

type NewFunc func(c Controller) (Interface, error)

NewFunc intializes the provider

Jump to

Keyboard shortcuts

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