httpapi

package
v0.0.0-...-9c13256 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2016 License: BSD-2-Clause Imports: 12 Imported by: 0

Documentation

Overview

Collection management handlers.

Document management handlers.

Index management handlers.

Miscellaneous function handlers.

Query handlers.

Register HTTP API endpoints and handle authorization requirements.

Without specifying authorization parameters in the command line, tiedot server does not require any authorization on any endpoint.

tiedot supports two authorization mechanisms: - Pre-shared authorization token The API endpoints will require 'Authorization: token PRE_SHARED_TOKEN' header. The pre-shared token is specified in command line parameter "-authtoken". Client request example: curl -I -H "Authorization: token PRE_SHARED_TOKEN" http://127.0.0.1:8080/all - JWT (JSON Web Token) The sophisticated mechanism offers finer-grained access control, separated by individual users. Access to specific endpoints are granted explicitly to each user.

These API endpoints will never require authorization: / (root), /version, and /memstats

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

This section is empty.

Jump to

Keyboard shortcuts

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