handlers

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2024 License: MIT Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoggingHandler

func LoggingHandler(h http.Handler) http.Handler

Types

type CreateDatabaseInput

type CreateDatabaseInput struct {
	Name string `minLength:"7" query:"name" required:"true"`
}

type CreateDatabaseOutput

type CreateDatabaseOutput struct {
	Body Database
}

type CreateDatabaseStackInput

type CreateDatabaseStackInput struct {
	URLParamDatabaseID
	Name string `minLength:"7" query:"name" required:"true"`
}

type Database

type Database struct {
	ID             string `json:"id"`
	Name           string `json:"name"`
	NumberOfStacks int    `json:"number_of_stacks"`
}

type DatabaseOutput

type DatabaseOutput struct {
	Body Database
}

type DatabaseStackInput

type DatabaseStackInput struct {
	URLParamDatabaseID
	URLParamStackID
}

type DatabasesOutput

type DatabasesOutput struct {
	Body struct {
		Databases         []Database `json:"databases"`
		NumberOfDatabases int        `json:"number_of_databases"`
	}
}

type Option added in v0.0.7

type Option func(*Service)

func WithBuildInfo added in v0.1.0

func WithBuildInfo(buildInfo *debug.BuildInfo) Option

func WithPersistDB added in v0.0.7

func WithPersistDB(persist bool) Option

func WithPort added in v0.0.7

func WithPort(port int32) Option

func WithRepoFile added in v0.1.0

func WithRepoFile(repofile string) Option

func WithSecure added in v0.1.0

func WithSecure(secure bool) Option

type PingOutput

type PingOutput struct {
	Body []byte `contentType:"text/plain"`
}

func PingHandler

func PingHandler(_ context.Context, _ *struct{}) (*PingOutput, error)

type PopDatabaseStackElementOutput

type PopDatabaseStackElementOutput struct {
	Body struct {
		Element any `json:"element"`
	}
	Status int
}

type PushDatabaseStackElementInput

type PushDatabaseStackElementInput struct {
	Body struct {
		Element any `json:"element"`
	}
	DatabaseStackInput
}

type Service

type Service struct {
	Repository *repository.Repository
	API        huma.API
	// contains filtered or unexported fields
}

func New

func New(opts ...Option) *Service

func (*Service) AddRoutes

func (s *Service) AddRoutes(api huma.API)

func (*Service) CreateDatabaseHandler

func (s *Service) CreateDatabaseHandler(_ context.Context, input *CreateDatabaseInput) (*CreateDatabaseOutput, error)

func (*Service) CreateDatabaseStackHandler

func (s *Service) CreateDatabaseStackHandler(_ context.Context, input *CreateDatabaseStackInput) (*StackOutput, error)

func (*Service) DeleteDatabaseHandler

func (s *Service) DeleteDatabaseHandler(_ context.Context, input *SingleDatabaseInput) (*struct{}, error)

func (*Service) DeleteDatabaseStackHandler

func (s *Service) DeleteDatabaseStackHandler(_ context.Context, input *DatabaseStackInput) (*struct{}, error)

func (*Service) FlushDatabaseStackHandler

func (s *Service) FlushDatabaseStackHandler(_ context.Context, input *DatabaseStackInput) (*StackOutput, error)

func (*Service) ListDatabaseStacksHandler

func (s *Service) ListDatabaseStacksHandler(_ context.Context, input *StackInput) (*StacksOutput, error)

func (*Service) ListDatabasesHandler

func (s *Service) ListDatabasesHandler(_ context.Context, _ *struct{}) (*DatabasesOutput, error)

func (*Service) LoadToFile added in v0.1.0

func (s *Service) LoadToFile() error

func (*Service) OpenAPI added in v0.0.6

func (s *Service) OpenAPI(openapi string) []byte

OpenAPI return the OpenAPI spec as a string in the requested version.

func (*Service) PeekDatabaseStackHandler

func (s *Service) PeekDatabaseStackHandler(_ context.Context, input *DatabaseStackInput) (*StackElement, error)

func (*Service) PopDatabaseStackHandler

func (s *Service) PopDatabaseStackHandler(_ context.Context, input *DatabaseStackInput) (*PopDatabaseStackElementOutput, error)

func (*Service) Port

func (s *Service) Port() int32

func (*Service) PushDatabaseStackHandler

func (s *Service) PushDatabaseStackHandler(_ context.Context, input *PushDatabaseStackElementInput) (*StackElement, error)

func (*Service) SaveToFile added in v0.1.0

func (s *Service) SaveToFile() error

func (*Service) ShowDatabaseHandler

func (s *Service) ShowDatabaseHandler(_ context.Context, input *SingleDatabaseInput) (*DatabaseOutput, error)

func (*Service) ShowDatabaseStackHandler

func (s *Service) ShowDatabaseStackHandler(_ context.Context, input *DatabaseStackInput) (*StackOutput, error)

func (*Service) Shutdown

func (s *Service) Shutdown(ctx context.Context) error

func (*Service) Start

func (s *Service) Start() error

func (*Service) StatusHandler

func (s *Service) StatusHandler(_ context.Context, _ *struct{}) (*StatusOutput, error)

type SingleDatabaseInput

type SingleDatabaseInput struct {
	URLParamDatabaseID
}

type Stack

type Stack struct {
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
	ReadAt    time.Time `json:"read_at"`
	Peek      any       `json:"peek"`
	ID        string    `json:"id"`
	Name      string    `json:"name"`
	Size      int       `json:"size"`
}

type StackElement

type StackElement struct {
	Body struct {
		Element any `json:"element"`
	}
}

type StackInput

type StackInput struct {
	URLParamDatabaseID
	KV bool `default:"false" query:"kv"`
}

type StackOutput

type StackOutput struct {
	Body Stack `json:"stack"`
}

type StacksOutput

type StacksOutput struct {
	Body struct {
		Stacks any `json:"stacks"`
	}
}

type StatusBody

type StatusBody struct {
	StartedAt        time.Time `json:"started_at"        yaml:"startedAt"`
	Code             string    `json:"status"            yaml:"code"`
	Version          string    `json:"version"           yaml:"version"`
	GoVersion        string    `json:"go_version"        yaml:"goVersion"`
	Host             string    `json:"host"              yaml:"host"`
	MemoryAlloc      string    `json:"memory_alloc"      yaml:"memoryAlloc"`
	RunningFor       float64   `json:"running_for"       yaml:"runningFor"`
	PID              int       `json:"pid"               yaml:"pid"`
	NumberGoroutines int       `json:"number_goroutines" yaml:"numberGoroutines"`
}

type StatusOutput

type StatusOutput struct {
	Body StatusBody
}

type URLParamDatabaseID

type URLParamDatabaseID struct {
	DatabaseID string `doc:"can be the database ID or name" path:"database"`
}

type URLParamStackID

type URLParamStackID struct {
	StackID string `doc:"can be the stack ID or name" path:"stack"`
}

Jump to

Keyboard shortcuts

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