server

package
v0.0.87 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2024 License: AGPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Connections is all connections
	// Sync syncs to store
	Sync           = store.Sync
	HomeDir        = ""
	HomeDirEnvFile = ""
)
View Source
var StandardRoutes = []echo.Route{
	{
		Name:        "Static",
		Method:      "GET",
		Path:        "/static/:folder/:name",
		Handler:     contentHandler,
		Middlewares: []echo.MiddlewareFunc{contentRewrite},
	},
	{
		Name:        "Assets Root",
		Method:      "GET",
		Path:        "/assets/:name",
		Handler:     contentHandler,
		Middlewares: []echo.MiddlewareFunc{contentRewrite},
	},
	{
		Name:        "Assets Connections",
		Method:      "GET",
		Path:        "/assets/:folder/:name",
		Handler:     contentHandler,
		Middlewares: []echo.MiddlewareFunc{contentRewrite},
	},
	{
		Name:    "getSettings",
		Method:  "GET",
		Path:    "/get-settings",
		Handler: GetSettings,
	},
	{
		Name:    "getHistory",
		Method:  "GET",
		Path:    "/get-history",
		Handler: GetHistory,
	},
	{
		Name:    "fileOperation",
		Method:  "POST",
		Path:    "/file-operation",
		Handler: PostFileOperation,
	},
	{
		Name:    "loadSession",
		Method:  "GET",
		Path:    "/load-session",
		Handler: GetLoadSession,
	},
	{
		Name:    "saveSession",
		Method:  "POST",
		Path:    "/save-session",
		Handler: PostSaveSession,
	},
}

Functions

func GetHistory

func GetHistory(c echo.Context) (err error)

GetHistory returns a a list of queries from the history.

func GetLoadSession

func GetLoadSession(c echo.Context) (err error)

GetLoadSession loads session from store

func GetSettings

func GetSettings(c echo.Context) (err error)

func PostFileOperation

func PostFileOperation(c echo.Context) (err error)

PostFileOperation operates with the file system

func PostSaveSession

func PostSaveSession(c echo.Context) (err error)

PostSaveSession saves a session to store

Types

type FileItem

type FileItem struct {
	Name  string `json:"name" query:"name"`
	Path  string `json:"path" query:"path"`
	IsDir bool   `json:"isDir" query:"isDir"`
	ModTs int64  `json:"modTs" query:"modTs"`
	Body  string `json:"body" query:"body"`
}

FileItem represents a file

type FileRequest

type FileRequest struct {
	Operation Operation `json:"operation" query:"operation"`
	File      FileItem  `json:"file" query:"file"`
	Overwrite bool      `json:"overwrite" query:"overwrite"`
}

FileRequest is the typical request struct for file operations

func (*FileRequest) Delete

func (f *FileRequest) Delete() (err error)

Delete deletes the file

func (*FileRequest) List

func (f *FileRequest) List() (items []FileItem, err error)

List lists files in a folder

func (*FileRequest) Read

func (f *FileRequest) Read() (file FileItem, err error)

Read opens the file

func (*FileRequest) Write

func (f *FileRequest) Write() (err error)

Write saves the file

type Operation

type Operation string
const (
	OperationList   Operation = "list"
	OperationRead   Operation = "read"
	OperationWrite  Operation = "write"
	OperationDelete Operation = "delete"
)

type Request

type Request struct {
	Name      string      `json:"name" query:"name"`
	Conn      string      `json:"conn" query:"conn"`
	Database  string      `json:"database" query:"database"`
	Schema    string      `json:"schema" query:"schema"`
	Table     string      `json:"table" query:"table"`
	Procedure string      `json:"procedure" query:"procedure"`
	Data      interface{} `json:"data" query:"data"`
}

Request is the typical request struct

type RouteName

type RouteName string

RouteName is the name of a route

const (
	// RouteWs is the websocket route
	RouteIndex RouteName = "/"
)

func (RouteName) String

func (r RouteName) String() string

type Server

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

Server is the main server

func NewServer

func NewServer() *Server

NewServer creates a new server

func (*Server) Close

func (srv *Server) Close()

func (*Server) Hostname

func (srv *Server) Hostname() string

func (*Server) Loop

func (srv *Server) Loop()

Loop cycles tasks

func (*Server) Start

func (srv *Server) Start()

Start starts the server

Jump to

Keyboard shortcuts

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