clu

package module
v0.0.0-...-083d3d8 Latest Latest
Warning

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

Go to latest
Published: May 7, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

README

Clu REST API (draft)

Introduction

The github.com/tknie/clu package contains an REST server to get and modify database data. No complex infrastructure inbetween, a direct connection to the database.

There should be no difference if the database is a SQL or a NoSQL database.

A list of data recrods should be able to be inserted or updated in one call. May be as transaction or in an atomic matter.

In advance real main database functionality should be contained like:

  • Create database tables
  • Read, Search, Insert, Update and Delete of data records
  • Search by passing database specific queries to be flexible for complex queries
  • One-to-One mapping of Golang structures to database tables
  • Large object support of big data
  • Support creating batch jobs for database-specific tasks like SQL scripts
  • Create index or other enhancements on database configuration

For details have a look at the API documentation. It can be referenced here: https://godoc.org/github.com/tknie/flynn

Example of Clu usage

Query records in database
Accept: application/json
Authorization: Base <base64>
GET http://localhost:8030/rest/view/Albums/ID,Title,published?limit=0&orderby=published:ASC
Update records in database
Accept: application/json
Authorization: Base <base64>
PUT http://localhost:8030/rest/view/Albums/ID,Title,published?limit=0&orderby=published:ASC
 {
  "Records": [
    {
      "id": "18",
      "title": "Der Ostergruss"
    },
 }
Insert records in database
Accept: application/json
Authorization: Base <base64>
PUSH http://localhost:8030/rest/view/Albums/ID,Title,published?limit=0&orderby=published:ASC

Check List

Feature Ready-State Description
Login database Draft
Query record Draft
Search record Draft
Insert record Draft
Delete record Draft
Load images out of database Draft
Load videos out of database Draft
Load binaries out of database Draft
Insert Large Object (Image, binary or others) Draft
Create table Draft
Insert database Draft
Work with batch queries planned
Complex search queries (common to SQL or NonSQL databases) planned

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Audit func(time.Time, *http.Request, error)

Audit callback function to be enabled

View Source
var DeleteUUID = false

DeleteUUID delete UUID after regular time frame

Functions

func AddUserInfo

func AddUserInfo(userInfo *auth.UserInfo) error

AddUserInfo add user if not already exists and create if not available

func CheckUserExist

func CheckUserExist(user string) *auth.UserInfo

CheckUserExist check user already exists and create if not available

func InitBatchRepository

func InitBatchRepository(dbRef *common.Reference, dbPassword, tablename string)

InitBatchRepository init batch repository

func InitStoreInfo

func InitStoreInfo(ref *common.Reference, password, tablename string)

InitStoreInfo init session info storage

func InitUserInfo

func InitUserInfo(ref *common.Reference, password, tablename string)

InitUserInfo init user info evaluation

func QueryUser

func QueryUser(user string) *auth.UserInfo

QueryUser query user information

Types

type BatchEntry

type BatchEntry struct {
	Name       string
	Query      string `flynn:":BLOB"`
	Database   string
	ParamCount int
}

BatchEntry entry of batch repository

func BatchSelect

func BatchSelect(batchname string) (*BatchEntry, error)

BatchSelect search for batchname in an batch repository

type Context

type Context struct {
	User *auth.UserInfo
	// User string
	Pass string
	Auth struct {
		Roles   []string
		Remote  string
		Session interface{}
	}
	Token string

	CurrentRequest *http.Request
	// contains filtered or unexported fields
}

Context server context

func NewContext

func NewContext(user, pass string) *Context

NewContext new server context with user and password

func NewContextUserInfo

func NewContextUserInfo(userInfo *auth.UserInfo, pass string) *Context

NewContextUserInfo new server context with user information and password

func (*Context) AddRoles

func (sc *Context) AddRoles(r []string)

AddRoles add roles interface function

func (*Context) Deadline

func (sc *Context) Deadline() (deadline time.Time, ok bool)

Deadline dead line

func (*Context) Done

func (sc *Context) Done() <-chan struct{}

Done context done

func (*Context) Err

func (sc *Context) Err() error

Err error return

func (*Context) GetData

func (sc *Context) GetData(key string) any

GetData entry specific storage of data is requested

func (*Context) Name

func (sc *Context) Name() string

Name Name interface function

func (*Context) Remote

func (sc *Context) Remote() string

Remote remote info interface function

func (*Context) Roles

func (sc *Context) Roles() []string

Roles roles info interface function

func (*Context) SendAuditError

func (sc *Context) SendAuditError(started time.Time, err error)

SendAuditError send audit error in context

func (*Context) Session

func (sc *Context) Session() interface{}

Session session info interface function

func (*Context) SetRemote

func (sc *Context) SetRemote(r string)

SetRemote set remote info interface function

func (*Context) SetSession

func (sc *Context) SetSession(s interface{})

SetSession set session info interface function

func (*Context) StoreData

func (sc *Context) StoreData(key string, value any)

StoreData entry specific storage of data

func (*Context) UUID

func (sc *Context) UUID() string

UUID UUID interface function

func (*Context) UserName

func (sc *Context) UserName() string

UserName user interface function

func (*Context) Value

func (sc *Context) Value(key any) any

Value value of key

type StoreJWTHandler

type StoreJWTHandler struct {
}

StoreJWTHandler store session in a database store

func (*StoreJWTHandler) InvalidateUUID

func (st *StoreJWTHandler) InvalidateUUID(uuid string, elapsed time.Time) bool

InvalidateUUID invalidate UUID entry and given elapsed time

func (*StoreJWTHandler) Range

func (st *StoreJWTHandler) Range(f func(uuid, value any) bool) error

Range go through all session entries

func (*StoreJWTHandler) Store

func (st *StoreJWTHandler) Store(principal auth.PrincipalInterface, user, pass string) (err error)

Store store entry for given input

func (*StoreJWTHandler) UUIDInfo

func (st *StoreJWTHandler) UUIDInfo(uuid string) (*auth.SessionInfo, error)

UUIDInfo get UUID info User information

func (*StoreJWTHandler) ValidateUUID

func (st *StoreJWTHandler) ValidateUUID(claims *auth.JWTClaims) (auth.PrincipalInterface, bool)

ValidateUUID validate JWT claims are in UUID session list

Directories

Path Synopsis
Code generated by ogen, DO NOT EDIT.
Code generated by ogen, DO NOT EDIT.
cmd

Jump to

Keyboard shortcuts

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