structs

package
v0.0.0-...-c201010 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Context

type Context struct {
	// App is the basic bootstrap information
	App GeneralInfo

	// Information about HTTP Server
	HTTPServer HTTPServerInfo

	// Database information
	DB DBInfo
}

Context holds information from bootstrap to be used

func (*Context) InitServer

func (ctx *Context) InitServer(logger *slog.Logger)

InitServer starts a new HTTP server or return an error

func (*Context) Shutdown

func (ctx *Context) Shutdown() error

Shutdown shutdown the HTTP server or returns an error

type DBInfo

type DBInfo struct {
	// Port number to be used
	Port uint

	// How many connections to use for connection pool
	MaxConnections uint

	// Host address
	Host string

	// Database name
	DBName string

	// Username to be connect with
	Username string

	// The password for the given username
	Password string

	// Configuration of the pool
	Config *pgxpool.Config

	// Pointer to the pool connection
	Pool *pgxpool.Pool
}

type GeneralInfo

type GeneralInfo struct {
	// Logger access
	Logger *slog.Logger

	// Quit channel
	Quit *chan bool
}

GeneralInfo of the application

type HTTPError

type HTTPError struct {
	// HTTP Status Code
	StatusCode int `example:"400" json:"status_code" validate:"required,min=400,max=599"`

	// Reason for the error
	Message string `example:"Something went wrong" json:"message" validate:"required"`

	// Additional information to provide (if existd)
	Info map[string]any `json:"info,omitempty" validate:"omitempty,omitnil"`
}

HTTPError holds information regarding HTTP request

type HTTPServerInfo

type HTTPServerInfo struct {
	// Raw port
	Port uint

	// Raw host
	Host string

	// How documentation will look (raw)
	ExternalHost string

	// Raw listen based on both Host and Port
	Listen string

	// web application
	App *echo.Echo
}

HTTPServerInfo holds information about the HTTP server

type User

type User struct {
	// User's first name
	FirstName string `json:"first_name" validate:"required,alphaunicode,max=15,min=2"`

	// User's middle name (if exists)
	MiddleName string `json:"middle_name,omitempty" validate:"min=0,max=15,omitempty,omitnil"`

	// User's last name
	LastName string `json:"last_name" validate:"required,alphaunicode,max=20,min=2"`

	// User's username that is in use
	Username string `json:"username" validate:"required,alphanumunicode|containsrune=.-_0x20100x20110x2015,max=24,min=2"`
}

func SetUser

func SetUser(buf []byte) (*User, error)

SetUser parse JSON request and validate the content

Jump to

Keyboard shortcuts

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