gowok

package module
v0.3.72 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2025 License: MIT Imports: 27 Imported by: 27

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HttpAccepted

func HttpAccepted(rw http.ResponseWriter, body any)

func HttpBadRequest

func HttpBadRequest(rw http.ResponseWriter, body any)

func HttpConflict

func HttpConflict(rw http.ResponseWriter, body any)

func HttpCreated

func HttpCreated(rw http.ResponseWriter, body any)

func HttpForbidden

func HttpForbidden(rw http.ResponseWriter)

func HttpInternalServerError

func HttpInternalServerError(rw http.ResponseWriter, body any)

func HttpNoContent

func HttpNoContent(rw http.ResponseWriter)

func HttpNotFound

func HttpNotFound(rw http.ResponseWriter)

func HttpOk

func HttpOk(rw http.ResponseWriter, body any)

func HttpUnauthorized

func HttpUnauthorized(rw http.ResponseWriter)

func Singleton added in v0.3.72

func Singleton[T any](singletonFunc singleton.SingletonFunc[T]) func(...T) *T

Singleton creates new object and gets if created. Deprecated: Use singleton.New instead.

Types

type Config

type Config struct {
	App      config.App
	Security config.Security
	SQLs     map[string]config.SQL  `yaml:"sql"`
	Http     map[string]config.Http `yaml:"http"`
	Smtp     map[string]config.Smtp `yaml:"smtp"`
	Others   map[string]string      `yaml:"others"`

	IsTesting bool   `yaml:"is_testing"`
	Env       string `yaml:"env"`
}

func NewConfig added in v0.3.72

func NewConfig(pathConfig string) (*Config, map[string]any, error)

type ConfigureFunc

type ConfigureFunc func(*Project)

type Hook added in v0.3.72

type Hook func()

type Hooks

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

func (*Hooks) OnStarted added in v0.3.72

func (h *Hooks) OnStarted(hook Hook)

func (*Hooks) OnStarting added in v0.3.72

func (h *Hooks) OnStarting(hook Hook)

func (*Hooks) OnStopped added in v0.3.72

func (h *Hooks) OnStopped(hook Hook)

type Pagination

type Pagination[T any] struct {
	Page        int `query:"page" json:"page"`
	PerPage     int `query:"per_page" json:"per_page"`
	TotalRecord int `json:"total_record"`

	Filter map[string]any    `query:"filter" json:"filter"`
	Fields []string          `query:"fields" json:"fields"`
	Sort   map[string]string `query:"sort" json:"sort"`

	Data []T `json:"data"`
}

func PaginationFromReq

func PaginationFromReq[T any](r *http.Request) Pagination[T]

func (Pagination[T]) MarshalJSON

func (p Pagination[T]) MarshalJSON() ([]byte, error)

func (*Pagination[T]) SetData

func (p *Pagination[T]) SetData(data ...T)

func (Pagination[T]) Skip

func (p Pagination[T]) Skip() int

func (Pagination[T]) TotalPage

func (p Pagination[T]) TotalPage() float64

type Project

type Project struct {
	Config    *Config
	ConfigMap map[string]any
	Runner    *runner.Runner
	Hooks     *Hooks
	SQL       getterByName[*sql.DB]
	Validator *Validator
	// contains filtered or unexported fields
}

func Get

func Get() *Project

func (*Project) Configures

func (p *Project) Configures(configures ...ConfigureFunc) *Project

func (*Project) GRPC added in v0.3.72

func (p *Project) GRPC() *grpc.Server

func (*Project) Reload added in v0.3.72

func (p *Project) Reload()

func (*Project) Run

func (p *Project) Run(forever ...bool)

type ValidationError added in v0.3.72

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

ValidationError represent error from validator

func NewValidationError added in v0.3.72

func NewValidationError(errs validator.ValidationErrors, translations ut.Translator, trans map[string]string) ValidationError

func ValidateJSON added in v0.3.72

func ValidateJSON[T any](r *http.Request, schema T, trans map[string]string) (*T, *ValidationError)

func (ValidationError) Error added in v0.3.72

func (err ValidationError) Error() string

func (ValidationError) MarshalJSON added in v0.3.72

func (err ValidationError) MarshalJSON() ([]byte, error)

type Validator added in v0.3.72

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

Validator struct

func NewValidator added in v0.3.72

func NewValidator() *Validator

NewValidator create an instance of Validator Struct

func (*Validator) SetTranslator added in v0.3.72

func (v *Validator) SetTranslator(trans ut.Translator, localeFunc func(*validator.Validate, ut.Translator) error) error

func (*Validator) ValidateStruct added in v0.3.72

func (v *Validator) ValidateStruct(input any, trans map[string]string) ValidationError

ValidateStruct func

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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