godd

package module
v0.0.68 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 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 GetOneFromArray added in v0.0.59

func GetOneFromArray(list ...interface{}) interface{}

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 {
	// contains filtered or unexported fields
}

func NewContext added in v0.0.47

func NewContext(i InterfaceContext, service interface{}, serviceOptionList map[string]interface{}, state map[string]interface{}, i18n *I18N) *Context

func NewContextDefault added in v0.0.55

func NewContextDefault() *Context

func (*Context) App added in v0.0.52

func (context *Context) App() InterfaceContext

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) SetApp added in v0.0.54

func (context *Context) SetApp(i InterfaceContext)

func (*Context) SetDefaultStruct added in v0.0.52

func (context *Context) SetDefaultStruct(i interface{}) interface{}

SetDefaultStruct 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

func (*Context) ValidateStruct added in v0.0.52

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

ValidateStruct 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"
	FrameWorkNetHTTP   FrameWork = "net/http"
)

type FuncEnvironment added in v0.0.35

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

type Handler

type Handler func(*Context) 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 InterfaceAMQP added in v0.0.56

type InterfaceAMQP interface {
}

InterfaceAMQP interface

type InterfaceApp

type InterfaceApp interface {
	GetFramework() FrameWork
	App() interface{}
	SetApp(interface{})
	Listen(port string, extraList ...interface{}) error
	Shutdown() error
	Get(path string, context *Context, handleList ...Handler) InterfaceHTTP
	Group(path string, context *Context, handleList ...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

	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{})
}

InterfaceContext interface

type InterfaceHTTP added in v0.0.46

type InterfaceHTTP interface {
	Add(method string, path string, context *Context, handleList ...func(context *Context) error)
	Get(path string, context *Context, handleList ...func(context *Context) error)
	Post(path string, context *Context, handleList ...func(context *Context) error)
	Put(path string, context *Context, handleList ...func(context *Context) error)
	Patch(path string, context *Context, handleList ...func(context *Context) error)
	Delete(path string, context *Context, handleList ...func(context *Context) 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