godd

package module
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2021 License: MIT Imports: 7 Imported by: 9

README

GoDD : 2 Layered Domain-Driven Design Architecture for Monolith and Microservice for Go Fiber Framework

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EnvironmentSwitcher

func EnvironmentSwitcher(env string, Localhost int, Development int, UAT 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 APILifeCycle

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

APILifeCycle Struct

func (*APILifeCycle) GetHandlerLogic

func (api *APILifeCycle) GetHandlerLogic() HandlerLogic

GetHandlerLogic func

func (*APILifeCycle) GetMappingResponse

func (api *APILifeCycle) GetMappingResponse() MappingResponse

GetMappingResponse func

func (*APILifeCycle) GetMappingResponseStandard

func (api *APILifeCycle) GetMappingResponseStandard() MappingResponseStandard

GetMappingResponseStandard func

func (*APILifeCycle) GetOnPostAuth

func (api *APILifeCycle) GetOnPostAuth() HandlerCycle

GetOnPostAuth func

func (*APILifeCycle) GetOnPostHandler

func (api *APILifeCycle) GetOnPostHandler() OnPostHandler

GetOnPostHandler func

func (*APILifeCycle) GetOnPreAuth

func (api *APILifeCycle) GetOnPreAuth() HandlerCycle

GetOnPreAuth func

func (*APILifeCycle) GetOnPreHandler

func (api *APILifeCycle) GetOnPreHandler() OnPreHandler

GetOnPreHandler func

func (*APILifeCycle) GetOnPreResponse

func (api *APILifeCycle) GetOnPreResponse() OnPreResponse

GetOnPreResponse func

func (*APILifeCycle) GetOnStart

func (api *APILifeCycle) GetOnStart() HandlerCycle

GetOnStart func

func (*APILifeCycle) GetParseLanguage

func (api *APILifeCycle) GetParseLanguage() HandlerCycle

GetParseLanguage func

func (*APILifeCycle) GetParseRequest

func (api *APILifeCycle) GetParseRequest() ParseRequest

GetParseRequest func

func (*APILifeCycle) GetSendResponse

func (api *APILifeCycle) GetSendResponse() SendResponse

GetSendResponse func

func (*APILifeCycle) GetValidateAuth

func (api *APILifeCycle) GetValidateAuth() HandlerCycle

GetValidateAuth func

func (*APILifeCycle) GetValidateHeader

func (api *APILifeCycle) GetValidateHeader() HandlerCycle

GetValidateHeader func

func (*APILifeCycle) GetValidateParam

func (api *APILifeCycle) GetValidateParam() ValidateParam

GetValidateParam func

func (*APILifeCycle) GetValidateQuery

func (api *APILifeCycle) GetValidateQuery() ValidateQuery

GetValidateQuery func

func (*APILifeCycle) GetValidateRequest

func (api *APILifeCycle) GetValidateRequest() ValidateRequest

GetValidateRequest func

func (*APILifeCycle) GetValidateResponse

func (api *APILifeCycle) GetValidateResponse() ValidateResponse

GetValidateResponse func

func (*APILifeCycle) HandlerLogic

func (api *APILifeCycle) HandlerLogic(handler HandlerLogic)

HandlerLogic func

func (*APILifeCycle) MappingResponse

func (api *APILifeCycle) MappingResponse(handler MappingResponse)

MappingResponse func

func (*APILifeCycle) MappingResponseStandard

func (api *APILifeCycle) MappingResponseStandard(handler MappingResponseStandard)

MappingResponseStandard func

func (*APILifeCycle) OnPostAuth

func (api *APILifeCycle) OnPostAuth(handler HandlerCycle)

OnPostAuth func

func (*APILifeCycle) OnPostHandler

func (api *APILifeCycle) OnPostHandler(handler OnPostHandler)

OnPostHandler func

func (*APILifeCycle) OnPreAuth

func (api *APILifeCycle) OnPreAuth(handler HandlerCycle)

OnPreAuth func

func (*APILifeCycle) OnPreHandler

func (api *APILifeCycle) OnPreHandler(handler OnPreHandler)

OnPreHandler func

func (*APILifeCycle) OnPreResponse

func (api *APILifeCycle) OnPreResponse(handler OnPreResponse)

OnPreResponse func

func (*APILifeCycle) OnStart

func (api *APILifeCycle) OnStart(handler HandlerCycle)

OnStart func

func (*APILifeCycle) ParseLanguage

func (api *APILifeCycle) ParseLanguage(handler HandlerCycle)

ParseLanguage func

func (*APILifeCycle) ParseRequest

func (api *APILifeCycle) ParseRequest(handler ParseRequest)

ParseRequest func

func (*APILifeCycle) SendResponse

func (api *APILifeCycle) SendResponse(handler SendResponse)

SendResponse func

func (*APILifeCycle) ValidateAuth

func (api *APILifeCycle) ValidateAuth(handler HandlerCycle)

ValidateAuth func

func (*APILifeCycle) ValidateHeader

func (api *APILifeCycle) ValidateHeader(handler HandlerCycle)

ValidateHeader func

func (*APILifeCycle) ValidateParam

func (api *APILifeCycle) ValidateParam(handler ValidateParam)

ValidateParam func

func (*APILifeCycle) ValidateQuery

func (api *APILifeCycle) ValidateQuery(handler ValidateQuery)

ValidateQuery func

func (*APILifeCycle) ValidateRequest

func (api *APILifeCycle) ValidateRequest(handler ValidateRequest)

ValidateRequest func

func (*APILifeCycle) ValidateResponse

func (api *APILifeCycle) ValidateResponse(handler ValidateResponse)

ValidateResponse func

type Error

type Error struct {
	Code          int // Please Use http.Status
	Error         error
	ErrorValidate *map[string]ErrorValidate
}

Error Struct

func ValidateStruct

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

ValidateStruct func

type ErrorValidate

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

ErrorValidate struct

type ErrorValidateReason

type ErrorValidateReason struct {
}

ErrorValidateReason struct

type FrameWork

type FrameWork string

FrameWork type

var (
	// FrameWorkGofiber FrameWork
	FrameWorkGofiber FrameWork = "gofiber"
)

type Handler

type Handler func(InterfaceContext) error

Handler type

type HandlerByPass

type HandlerByPass = func(service interface{}, serviceOptionList map[string]interface{}) Handler

HandlerByPass Type

type HandlerCycle

type HandlerCycle = func(context InterfaceContext) (err *Error)

HandlerCycle Type

type HandlerLogic

type HandlerLogic = func(context InterfaceContext, requestValidatedBody interface{}, requestValidatedParam interface{}, requestValidatedQuery interface{}) (code int, responseRaw interface{}, responsePagination *ResponsePagination, err *Error)

HandlerLogic 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) MustLocalize

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

MustLocalize func

type InterfaceApp

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

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{}, responseCode ...int) error
	Redirect(location string, responseCode ...int) error

	SetContext(service interface{}, serviceOptionList map[string]interface{}, i18n *I18N, state map[string]interface{})
	GetService() interface{}
	GetServiceOptionList(name string) interface{}
	GetState(name string) interface{}
	SetState(name string, value interface{})

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

	SetLang(lang string)
	GetLang() string
	MustLocalize(id string, data Map, count int, m ...interface{}) string

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

InterfaceContext interface

type InterfaceRouter

type InterfaceRouter 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)
}

InterfaceRouter interface

type Map

type Map map[string]interface{}

Map type

type MappingResponse

type MappingResponse = func(context InterfaceContext, code int, responseRaw interface{}, responsePagination *ResponsePagination) (codeOut int, responseMapping interface{}, responsePaginationOut *ResponsePagination, err *Error)

MappingResponse Type

type MappingResponseStandard

type MappingResponseStandard = func(context InterfaceContext, code int, responseRaw interface{}, responsePagination *ResponsePagination) (codeOut int, responseMapping interface{}, err *Error)

MappingResponseStandard Type

type OnPostHandler

type OnPostHandler = func(context InterfaceContext, code int, responseRawIn interface{}, responsePagination *ResponsePagination) (codeOut int, responseRawOut interface{}, responsePaginationOut *ResponsePagination, err *Error)

OnPostHandler Type

type OnPreHandler

type OnPreHandler = func(context InterfaceContext, requestValidatedBody interface{}, requestValidatedParam interface{}, requestValidatedQuery interface{}) (requestValidatedBodyOut interface{}, requestValidatedParamOut interface{}, requestValidatedQueryOut interface{}, err *Error)

OnPreHandler Type

type OnPreResponse

type OnPreResponse = func(context InterfaceContext, code int, requestValidatedIn interface{}) (codeOut int, requestValidatedOut interface{}, err *Error)

OnPreResponse Type

type ParseRequest

type ParseRequest = func(context InterfaceContext) (requestMappingBody interface{}, err *Error)

ParseRequest Type

type RequestFilter

type RequestFilter struct {
}

RequestFilter 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 ResponseDataList

type ResponseDataList struct {
	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"` // errors don't define JSON marshaling`
}

ResponseDataList for Send Response Message to Encode Response

type ResponseError

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

ResponseError 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

type SendResponse

type SendResponse = func(context InterfaceContext, code int, requestValidated interface{}) (err *Error)

SendResponse Type

type ValidateParam

type ValidateParam = func(context InterfaceContext) (requestValidatedParam interface{}, err *Error)

ValidateParam Type

type ValidateQuery

type ValidateQuery = func(context InterfaceContext) (requestValidatedQuery interface{}, err *Error)

ValidateQuery Type

type ValidateRequest

type ValidateRequest = func(context InterfaceContext, requestMappingBody interface{}) (requestValidatedBody interface{}, err *Error)

ValidateRequest Type

type ValidateResponse

type ValidateResponse = func(context InterfaceContext, code int, responseMapping interface{}, responsePagination *ResponsePagination) (codeOut int, responseValidated interface{}, responsePaginationOut *ResponsePagination, err *Error)

ValidateResponse Type

Directories

Path Synopsis
example
support

Jump to

Keyboard shortcuts

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