httpapi

package
v0.0.0-...-ae1e168 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2021 License: BSD-2-Clause Imports: 14 Imported by: 16

Documentation

Index

Constants

View Source
const (
	// JWT Record and claim
	JWT_COL_NAME         = "jwt"
	JWT_USER_ATTR        = "user"
	JWT_PASS_ATTR        = "pass"
	JWT_ENDPOINTS_ATTR   = "endpoints"
	JWT_COLLECTIONS_ATTR = "collections"
	JWT_USER_ADMIN       = "admin"
	// JWT claim
	JWT_EXPIRY = "exp"
)

Variables

View Source
var (
	HttpDB *db.DB // HTTP API endpoints operate on this database
)

Functions

func All

func All(w http.ResponseWriter, r *http.Request)

Return all collection names.

func ApproxDocCount

func ApproxDocCount(w http.ResponseWriter, r *http.Request)

Return approximate number of documents in the collection.

func Count

func Count(w http.ResponseWriter, r *http.Request)

Execute a query and return number of documents from the result.

func Create

func Create(w http.ResponseWriter, r *http.Request)

Create a collection.

func Delete

func Delete(w http.ResponseWriter, r *http.Request)

Delete a document.

func Drop

func Drop(w http.ResponseWriter, r *http.Request)

Drop a collection.

func Dump

func Dump(w http.ResponseWriter, r *http.Request)

Copy this database into destination directory.

func Get

func Get(w http.ResponseWriter, r *http.Request)

Find and retrieve a document by ID.

func GetPage

func GetPage(w http.ResponseWriter, r *http.Request)

Divide documents into roughly equally sized pages, and return documents in the specified page.

func Index

func Index(w http.ResponseWriter, r *http.Request)

Put an index on a document path.

func Indexes

func Indexes(w http.ResponseWriter, r *http.Request)

Return all indexed paths.

func Insert

func Insert(w http.ResponseWriter, r *http.Request)

Insert a document into collection.

func MemStats

func MemStats(w http.ResponseWriter, r *http.Request)

Return server memory statistics.

func Query

func Query(w http.ResponseWriter, r *http.Request)

Execute a query and return documents from the result.

func Rename

func Rename(w http.ResponseWriter, r *http.Request)

Rename a collection.

func Require

func Require(w http.ResponseWriter, r *http.Request, key string, val *string) bool

Store form parameter value of specified key to *val and return true; if key does not exist, set HTTP status 400 and return false.

func Scrub

func Scrub(w http.ResponseWriter, r *http.Request)

De-fragment collection free space and fix corrupted documents.

func Shutdown

func Shutdown(w http.ResponseWriter, r *http.Request)

Flush and close all data files and shutdown the entire program.

func Start

func Start(dir string, port int, tlsCrt, tlsKey, jwtPubKey, jwtPrivateKey, bind, authToken string)

Start HTTP server and block until the server shuts down. Panic on error.

func Sync

func Sync(w http.ResponseWriter, r *http.Request)

Noop

func Unindex

func Unindex(w http.ResponseWriter, r *http.Request)

Remove an indexed path.

func Update

func Update(w http.ResponseWriter, r *http.Request)

Update a document.

func Version

func Version(w http.ResponseWriter, r *http.Request)

Return server protocol version number.

func Welcome

func Welcome(w http.ResponseWriter, r *http.Request)

Greet user with a welcome message.

Types

type TokenExtractor

type TokenExtractor struct {
}

Extract JWT from Authorization header or "access_token" attribute.

func (TokenExtractor) ExtractToken

func (t TokenExtractor) ExtractToken(req *http.Request) (string, error)

Jump to

Keyboard shortcuts

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