server

package
v0.0.70 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2024 License: GPL-3.0 Imports: 20 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var StandardRoutes = []echo.Route{
	{
		Name:    "getStatus",
		Method:  "GET",
		Path:    "/.status",
		Handler: getStatus,
	},
	{
		Name:    "getConnections",
		Method:  "GET",
		Path:    "/.connections",
		Handler: getConnections,
	},
	{
		Name:    "getConnectionDatabases",
		Method:  "GET",
		Path:    "/:connection/.databases",
		Handler: getConnectionDatabases,
	},
	{
		Name:    "getConnectionSchemas",
		Method:  "GET",
		Path:    "/:connection/.schemas",
		Handler: getConnectionSchemas,
	},
	{
		Name:    "getConnectionTables",
		Method:  "GET",
		Path:    "/:connection/.tables",
		Handler: getConnectionTables,
	},
	{
		Name:    "getConnectionColumns",
		Method:  "GET",
		Path:    "/:connection/.columns",
		Handler: getConnectionColumns,
	},
	{
		Name:    "submitSQL",
		Method:  "POST",
		Path:    "/:connection/.sql",
		Handler: postConnectionSQL,
	},
	{
		Name:    "submitSQL_ID",
		Method:  "POST",
		Path:    "/:connection/.sql/:id",
		Handler: postConnectionSQL,
	},
	{
		Name:    "cancelSQL",
		Method:  "POST",
		Path:    "/:connection/.cancel/:id",
		Handler: postConnectionCancel,
	},
	{
		Name:    "getSchemaTables",
		Method:  "GET",
		Path:    "/:connection/:schema/.tables",
		Handler: getSchemaTables,
	},
	{
		Name:    "getSchemaColumns",
		Method:  "GET",
		Path:    "/:connection/:schema/.columns",
		Handler: getSchemaColumns,
	},
	{
		Name:    "getTableColumns",
		Method:  "GET",
		Path:    "/:connection/:schema/:table/.columns",
		Handler: getTableColumns,
	},
	{
		Name:    "getTableIndexes",
		Method:  "GET",
		Path:    "/:connection/:schema/:table/.indexes",
		Handler: getTableIndexes,
	},
	{
		Name:    "getTableKeys",
		Method:  "GET",
		Path:    "/:connection/:schema/:table/.keys",
		Handler: getTableKeys,
	},
	{
		Name:    "tableInsert",
		Method:  "POST",
		Path:    "/:connection/:schema/:table",
		Handler: postTableInsert,
	},
	{
		Name:    "tableUpsert",
		Method:  "PUT",
		Path:    "/:connection/:schema/:table",
		Handler: postTableUpsert,
	},
	{
		Name:    "tableUpdate",
		Method:  "PATCH",
		Path:    "/:connection/:schema/:table",
		Handler: patchTableUpdate,
	},
	{
		Name:    "getTableSelect",
		Method:  "GET",
		Path:    "/:connection/:schema/:table",
		Handler: getTableSelect,
	},
}

Functions

func ErrJSON

func ErrJSON(HTTPStatus int, err error, args ...interface{}) error

ErrJSON returns to the echo.Context as JSON formatted

func ProcessRequest

func ProcessRequest(req Request, reqFunc ReqFunction) (data iop.Dataset, err error)

ProcessRequest processes the request with the given function

func StringRecords added in v0.0.60

func StringRecords(data *iop.Dataset) []map[string]interface{}

Records return rows of maps or string values

Types

type ReqFunction

type ReqFunction func(c database.Connection, req Request) (iop.Dataset, error)

ReqFunction is the request function type

type Request

type Request struct {
	ID         string `json:"id" query:"id"` // used for query ID
	Name       string `json:"name" query:"name"`
	Connection string `json:"connection" query:"connection"`
	Database   string `json:"database" query:"database"`
	Schema     string `json:"schema" query:"schema"`
	Table      string `json:"table" query:"table"`
	Query      string `json:"query" query:"query"`
	Procedure  string `json:"procedure" query:"procedure"`
	Data       any    `json:"data" query:"data"`

	Project *state.Project `json:"-" query:"-"`

	Header http.Header `json:"-" query:"-"`

	Roles       state.RoleMap     `json:"-" query:"-"`
	Permissions state.Permissions `json:"-" query:"-"`
	// contains filtered or unexported fields
}

Request is the typical request struct

func NewRequest

func NewRequest(c echo.Context) Request

func (*Request) CanRead

func (r *Request) CanRead(table database.Table) bool

func (*Request) CanWrite

func (r *Request) CanWrite(table database.Table) bool

func (*Request) GetDatastream

func (req *Request) GetDatastream() (ds *iop.Datastream, err error)

func (*Request) GetFileUpload

func (r *Request) GetFileUpload() (src io.ReadCloser, err error)

func (*Request) URL added in v0.0.36

func (r *Request) URL() *url.URL

func (*Request) Validate

func (r *Request) Validate(checks ...requestCheck) (err error)

type Response

type Response struct {
	Request Request        `json:"-"`
	Error   string         `json:"error,omitempty"`
	Payload map[string]any `json:"-"`
	Status  int            `json:"-"`

	Header http.Header `json:"-" query:"-"`
	// contains filtered or unexported fields
}

func NewResponse

func NewResponse(req Request) Response

func (*Response) Make

func (r *Response) Make() (err error)

func (*Response) MakeStreaming

func (r *Response) MakeStreaming() (err error)

type Server

type Server struct {
	Port       string
	EchoServer *echo.Echo
	StartTime  time.Time
}

Server is the main server

func NewServer

func NewServer() (s *Server)

func (*Server) Close

func (s *Server) Close()

func (*Server) Hostname

func (s *Server) Hostname() string

func (*Server) Start

func (s *Server) Start()

Jump to

Keyboard shortcuts

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