app

package
v0.0.0-...-4403df5 Latest Latest
Warning

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

Go to latest
Published: May 10, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConnectionToDB

func ConnectionToDB(srv *App, dbStruct config.Database) error

ConnectionToDB connects to the database and sets the connection to the App

func RunCommand

func RunCommand(script string, out chan<- string, errChan chan<- error)

RunCommand runs a bash script and returns the output or an error doing this asynchronously

Types

type App

type App struct {
	Db     *sql.DB
	Router *mux.Router
	// contains filtered or unexported fields
}

func Run

func Run(cfg *config.Config) (*App, error)

Run SetupRoutes sets up the routes for the application

func (*App) AllCommands

func (a *App) AllCommands() ([]CommandSmallInfo, error)

AllCommands returns all commands from the database

func (*App) AlreadyExist

func (a *App) AlreadyExist(data *Table) bool

AlreadyExist checks if a command already exists in the database

func (*App) GracefulStop

func (a *App) GracefulStop(serverCtx context.Context, sig <-chan os.Signal, serverStopCtx context.CancelFunc)

GracefulStop stops the server gracefully

func (*App) InfoAll

func (a *App) InfoAll(w http.ResponseWriter, r *http.Request)

InfoAll returns all commands

func (*App) InfoCommand

func (a *App) InfoCommand(param string) ([]Table, error)

InfoCommand returns a command by id or list of commands by ids

func (*App) InfoCommands

func (a *App) InfoCommands(w http.ResponseWriter, r *http.Request)

InfoCommands returns a command by id or list of commands by ids

func (*App) InsertCommand

func (a *App) InsertCommand(data *Table) error

InsertCommand inserts a command into the database and runs it

func (*App) NewCommand

func (a *App) NewCommand(w http.ResponseWriter, r *http.Request)

NewCommand creates a new command in the database

func (*App) Remove

func (a *App) Remove(param string) error

Remove removes a command or multiple commands from the database

func (*App) RemoveCommand

func (a *App) RemoveCommand(w http.ResponseWriter, r *http.Request)

RemoveCommand removes a command or multiple commands from the database

func (*App) SetupRoutes

func (a *App) SetupRoutes() http.Handler

type CommandSmallInfo

type CommandSmallInfo struct {
	Id   int64
	Name string
}

type Table

type Table struct {
	Id          int64
	Name        string
	Script      string
	Description string
	Output      string
}

Jump to

Keyboard shortcuts

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