router

package
v0.1.12 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package router contains the handler for the database

Index

Constants

View Source
const (
	GET    methodType = "GET"
	POST   methodType = "POST"
	PUT    methodType = "PUT"
	DELETE methodType = "DELETE"
)

Variables

This section is empty.

Functions

func CORS

func CORS() func(next http.Handler) http.Handler

func MountRouter

func MountRouter(handler DBHandler, cfg *configs.Config) (*http.ServeMux, error)

func NewAPI added in v0.1.7

func NewAPI(mux *http.ServeMux, cfg *configs.Config) huma.API

func RegisterRoutes added in v0.1.7

func RegisterRoutes(api huma.API, h DBHandler)

Types

type BaseHTMLData

type BaseHTMLData struct {
	Tables []models.ListTablesRow
	Cols   []models.ColValue
}

type CreeteNewTableInput added in v0.1.7

type CreeteNewTableInput struct {
	Body struct {
		TableName string            `json:"tableName"`
		Inputs    []models.ColValue `json:"inputs"`
	}
}

type DBHandler

type DBHandler struct {
	// contains filtered or unexported fields
}

func NewHandler

func NewHandler(service service.DBService, itemsLimit int) DBHandler

func (DBHandler) CreeteNewTable

func (h DBHandler) CreeteNewTable(ctx context.Context, input *CreeteNewTableInput) (*struct{}, error)

func (DBHandler) DeleteRow

func (h DBHandler) DeleteRow(ctx context.Context, input *DeleteRowInput) (*struct{}, error)

func (*DBHandler) DeleteTable

func (h *DBHandler) DeleteTable(ctx context.Context, input *struct{ Body DeleteTableRequest }) (*struct{}, error)

func (*DBHandler) HandleRunSQLQuery added in v0.1.7

func (h *DBHandler) HandleRunSQLQuery(ctx context.Context, input *RunSQLQueryInput) (*RunSQLQueryOutput, error)

func (DBHandler) InsertOrUpdateRow

func (h DBHandler) InsertOrUpdateRow(ctx context.Context, input *InsertOrUpdateRowInput) (*struct{}, error)

func (DBHandler) ListColumns

func (h DBHandler) ListColumns(ctx context.Context, input *ListColumnsInput) (*struct{ Body []models.ColValue }, error)

func (*DBHandler) ListHistory

func (h *DBHandler) ListHistory(ctx context.Context, input *ListHistoryInput) (*struct{ Body []models.History }, error)

func (*DBHandler) ListRecentHistory

func (h *DBHandler) ListRecentHistory(ctx context.Context, input *struct{}) (*struct{ Body []models.History }, error)

func (DBHandler) ListRows

func (h DBHandler) ListRows(ctx context.Context, input *ListRowsInput) (*ListRowsOutput, error)

func (DBHandler) ListTables

func (h DBHandler) ListTables(ctx context.Context, input *struct{}) (*struct{ Body []models.ListTablesRow }, error)

func (DBHandler) NewTableFormFileds

func (h DBHandler) NewTableFormFileds(ctx context.Context, input *struct{}) (*struct{ Body *service.FormDatatype }, error)

func (DBHandler) RowInsertOrUpdateForm added in v0.1.7

func (h DBHandler) RowInsertOrUpdateForm(ctx context.Context, input *RowInsertOrUpdateFormInput) (*RowInsertOrUpdateFormOutput, error)

type DeleteRowInput added in v0.1.7

type DeleteRowInput struct {
	TableName string `path:"tableName"`
	Hash      string `path:"hash"`
	Page      int    `query:"page" default:"1"`
}

type DeleteTableRequest

type DeleteTableRequest struct {
	TableName         string `json:"tableName"`
	VerificationQuiry string `json:"verificationQuery"`
}

type ErrorMessage

type ErrorMessage struct {
	Message string
}

type InsertOrUpdateRowInput added in v0.1.7

type InsertOrUpdateRowInput struct {
	TableName string            `path:"tableName"`
	Hash      string            `query:"hash"`
	Page      int               `query:"page" default:"1"`
	Body      []models.ColValue `json:"body"`
}

type ListColumnsInput added in v0.1.7

type ListColumnsInput struct {
	TableName string `path:"tableName"`
}

type ListHistoryInput added in v0.1.7

type ListHistoryInput struct {
	Page int `query:"page" default:"1"`
}

type ListRowsInput added in v0.1.7

type ListRowsInput struct {
	TableName string `path:"tableName"`
	Page      int    `query:"page" default:"1" minimum:"1"`
	Column    string `query:"column"`
	Order     string `query:"order" enum:"ASC,DESC"`
}

type ListRowsOutput added in v0.1.7

type ListRowsOutput struct {
	Body ListRowsResponse
}

type ListRowsResponse

type ListRowsResponse struct {
	Page        int               `json:"page"`
	Rows        []models.RowSet   `json:"rows"`
	Cols        []models.ColValue `json:"cols"`
	RowCount    int               `json:"rowCount"`
	ActiveTable string            `json:"activeTable"`
	HasNextPage bool              `json:"hasNextPage"`
	TotalPages  int               `json:"totalPages"`
}

type RowInsertOrUpdateFormInput added in v0.1.7

type RowInsertOrUpdateFormInput struct {
	TableName string `path:"tableName"`
	Page      int    `query:"page" default:"1" minimum:"1"`
	Hash      string `query:"hash"`
}

type RowInsertOrUpdateFormOutput added in v0.1.7

type RowInsertOrUpdateFormOutput struct {
	Body struct {
		Cols []models.ColValue `json:"cols"`
	}
}

type RunSQLQueryInput added in v0.1.7

type RunSQLQueryInput struct {
	Body struct {
		Query string `json:"query"`
	}
}

type RunSQLQueryOutput added in v0.1.7

type RunSQLQueryOutput struct {
	Body struct {
		*models.RunSQLQueryOutput
	}
}

Jump to

Keyboard shortcuts

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