godd

package module
v0.0.48 Latest Latest
Warning

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

Go to latest
Published: May 14, 2021 License: MIT Imports: 10 Imported by: 9

README

GO-DD : Golang Backend Standard with 2 Layered Domain-Driven Design Architecture

GO-DD not a framework but is a standard and architecture pattern for easy communicate in your team. it helpful with api life-cycle pattern function for manage code propose

Support Monolith and Microservice (Primary Base On Go Fiber Framework)

Community

discord : https://discord.com/channels/815474338588655637/
facebook : https://www.facebook.com/groups/goddthailand/

Sponser

Buy Me a Salmon
    A-Value Co.,Ltd : x 1 🍣



Buy Me a Coffee

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertToArray added in v0.0.6

func ConvertToArray(dataList interface{}) []interface{}

ConvertToArray func

func EnvironmentSwitcher

func EnvironmentSwitcher(env string, Localhost int, Development int, Testing int, Staging int, Production int, i ...interface{}) interface{}

EnvironmentSwitcher func

func IsInterfaceIsNil

func IsInterfaceIsNil(i interface{}) bool

IsInterfaceIsNil func

func MustError

func MustError(err error, strList ...string)

MustError Func

func SetDefaultStruct

func SetDefaultStruct(variable interface{}) interface{}

SetDefaultStruct func

Types

type Context added in v0.0.46

type Context struct {
	Service           interface{}
	ServiceOptionList map[string]interface{}
	State             map[string]interface{}
	I18n              *I18N
}

func NewContext added in v0.0.47

func NewContext(Service interface{}, ServiceOptionList map[string]interface{}, State map[string]interface{}, I18n *I18N) *Context

func (*Context) ClearState added in v0.0.46

func (context *Context) ClearState()

ClearState func

func (*Context) GetI18N added in v0.0.46

func (context *Context) GetI18N() *I18N

GetI18N func

func (*Context) GetLang added in v0.0.46

func (context *Context) GetLang() string

GetLang func

func (*Context) GetService added in v0.0.46

func (context *Context) GetService() interface{}

GetService func

func (*Context) GetServiceOptionList added in v0.0.46

func (context *Context) GetServiceOptionList(name string) interface{}

GetServiceOptionList func

func (*Context) GetState added in v0.0.46

func (context *Context) GetState(name string) interface{}

GetState func

func (*Context) SetLang added in v0.0.46

func (context *Context) SetLang(lang string)

SetLang func

func (*Context) SetState added in v0.0.46

func (context *Context) SetState(name string, value interface{})

SetState func

type DeferClose added in v0.0.8

type DeferClose struct {
	Name string
	I    InterfaceClose
}

DeferClose struct

type Env added in v0.0.9

type Env string

Env type

const (
	// EnvLocalhost Env
	EnvLocalhost Env = "localhost"
	// EnvDevelopment Env
	EnvDevelopment Env = "development"
	// EnvTesting Env
	EnvTesting Env = "testing"
	// EnvStaging Env
	EnvStaging Env = "staging"
	// EnvProduction Env
	EnvProduction Env = "production"
)

type Error

type Error struct {
	Code int // Please Use http.Status

	Error error
	// contains filtered or unexported fields
}

Error Struct

func ErrorNew added in v0.0.35

func ErrorNew(code int, err error) *Error

Helper Error

func ValidateStruct

func ValidateStruct(i18n *I18N, i interface{}, iType map[string]interface{}) *Error

ValidateStruct func

func (*Error) GetErrorValidate added in v0.0.35

func (e *Error) GetErrorValidate() *map[string]ResponseErrorValidate

func (*Error) GetMessage added in v0.0.35

func (e *Error) GetMessage() string

func (*Error) IsContain added in v0.0.35

func (e *Error) IsContain(subString string) bool

func (*Error) IsContainSetError added in v0.0.35

func (e *Error) IsContainSetError(subString string, errorString string)

func (*Error) SetError added in v0.0.35

func (e *Error) SetError(str string)

func (*Error) SetErrorValidate added in v0.0.35

func (e *Error) SetErrorValidate(errorValidate *map[string]ResponseErrorValidate)

func (*Error) SetMessage added in v0.0.35

func (e *Error) SetMessage(str string)

type FrameWork

type FrameWork string

FrameWork type

const (
	// FrameWorkGofiber FrameWork
	FrameWorkGofiberV2 FrameWork = "gofiber/v2"
)

type FuncEnvironment added in v0.0.35

type FuncEnvironment = func(secret MapString) (*Map, *[]DeferClose)

type Handler

type Handler func(InterfaceContext) error

Handler type

type I18N

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

I18N func

func NewI18N

func NewI18N(defaultLanguage language.Tag, formatUnmarshal string, unmarshalFunc i18n.UnmarshalFunc, fileLanguageList Map) *I18N

NewI18N func

func (*I18N) GetLang added in v0.0.4

func (i *I18N) GetLang() string

GetLang func

func (*I18N) MustLocalize

func (i *I18N) MustLocalize(id string, data Map, count int, m ...interface{}) string

MustLocalize func

func (*I18N) SetLang added in v0.0.4

func (i *I18N) SetLang(lang string)

SetLang func

type InterfaceApp

type InterfaceApp interface {
	GetFramework() FrameWork
	App() interface{}
	GetFrameworkApp() interface{}
	Listen(port string) error
	Shutdown() error
	Get(path string, handlers ...Handler) InterfaceHTTP
	Group(path string, handlers ...Handler) InterfaceHTTP
	IsSupportHTTP() bool
}

InterfaceApp interface

type InterfaceClose

type InterfaceClose interface {
	Close() error
}

InterfaceClose for Manage Defer Close

type InterfaceContext

type InterfaceContext interface {
	GetFramework() FrameWork
	GetFrameworkContext() interface{}
	Response(responseDataList interface{}, contentType string, responseCode ...int) error
	Redirect(location string, responseCode ...int) error

	SetContext(context *Context)
	GetContext() *Context

	SetContentType(str string)

	SetHeader(key string, val string)
	GetHeader(key string, defaultValue ...string) string

	GetQuery(key string, defaultValue ...string) string
	QueryParser(out interface{}) error

	GetParam(key string, defaultValue ...string) string

	GetBody() []byte
	BodyParser(out interface{}) error

	GetCookie(key string, val string)
	SetCookie(cookie interface{})

	ClearCookie(key ...string)

	Log(v ...interface{})

	ValidateStruct(i interface{}, iType map[string]interface{}) *Error
	SetDefaultStruct(i interface{}) interface{}
}

InterfaceContext interface

type InterfaceHTTP added in v0.0.46

type InterfaceHTTP interface {
	Add(method string, path string, handlers ...func(ctx InterfaceContext) error)
	Get(path string, handlers ...func(ctx InterfaceContext) error)
	Post(path string, handlers ...func(ctx InterfaceContext) error)
	Put(path string, handlers ...func(ctx InterfaceContext) error)
	Patch(path string, handlers ...func(ctx InterfaceContext) error)
	Delete(path string, handlers ...func(ctx InterfaceContext) error)
}

InterfaceHTTP interface

type Map

type Map map[string]interface{}

Map type

type MapString added in v0.0.7

type MapString map[string]string

MapString type

type RequestFilter

type RequestFilter struct {
	DateStart  string              `json:"date_start"`
	DateEnd    string              `json:"date_end"`
	FilterList []RequestFilterType `json:"filter"`
	SortList   []RequestSort       `json:"sort"`
}

RequestFilter Struct

type RequestFilterType added in v0.0.3

type RequestFilterType struct {
	Field    string `json:"field"`
	Operator string `json:"op"`
	Value    string `json:"value"`
}

RequestFilterType struct

type RequestPagination

type RequestPagination struct {
	Page     int `json:"page"      default:"1"  swaggertype:"integer"`
	PageSize int `json:"page_size" default:"10" swaggertype:"integer"`
}

RequestPagination Struct

type RequestSort added in v0.0.3

type RequestSort struct {
	Field string `json:"field"`
	By    string `json:"by"`
}

RequestSort struct

type ResponseDataList

type ResponseDataList struct {
	Code               int                 `json:"code"                 swaggertype:"integer"`
	Success            bool                `json:"success"              swaggertype:"boolean"`
	Message            string              `json:"message"              swaggertype:"string"`
	Data               interface{}         `json:"data,omitempty"       swaggertype:"object"`
	ResponsePagination *ResponsePagination `json:"pagination,omitempty" swaggertype:"object"`
	ResponseError      *ResponseError      `json:"error,omitempty"      swaggertype:"object"`
}

ResponseDataList for Send Response Message to Encode Response

type ResponseError

type ResponseError struct {
	Message  string                            `json:"message" swaggertype:"string"`
	Validate *map[string]ResponseErrorValidate `json:"validate,omitempty" swaggertype:"object"`
}

ResponseError Struct

type ResponseErrorValidate added in v0.0.6

type ResponseErrorValidate struct {
	Reason  string `json:"reason"`
	Message string `json:"message"`
	Param   string `json:"param,omitempty"`
}

ResponseErrorValidate struct

type ResponsePagination

type ResponsePagination struct {
	Page       int `json:"page"         swaggertype:"integer"`
	PageSize   int `json:"page_size"    swaggertype:"integer"`
	PageCount  int `json:"page_count"   swaggertype:"integer"`
	ItemCount  int `json:"item_count"   swaggertype:"integer"`
	TotalCount int `json:"total_count"  swaggertype:"integer"`
}

ResponsePagination Struct

func GetResponsePagination added in v0.0.35

func GetResponsePagination(requestPagination RequestPagination, totalCount int, itemCount int) *ResponsePagination

Jump to

Keyboard shortcuts

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