libRequest

package
v0.12.8 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2025 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const ModuleName = "RequestHandler"
View Source
const PaginationLocalTag string = "pagination"

Variables

This section is empty.

Functions

func TypeStrings added in v0.5.7

func TypeStrings() []string

TypeStrings returns a slice of all String values of the enum

Types

type EventData

type EventData struct {
	Time     time.Time `json:"dt"`
	ActionId string    `json:"action_id"`
	BranchId string    `json:"branch_id"`
	UserId   string    `json:"user_id"`
	Logs     []LogData `json:"logs"`
}

type LogData

type LogData struct {
	Time    time.Time `json:"dt"`
	Program string    `json:"program"`
	Module  string    `json:"module"`
	Method  string    `json:"method"`
	LogText string    `json:"log_text"`
}

type LogRequest added in v0.11.19

type LogRequest struct {
}

func (LogRequest) AddRequestEvent added in v0.11.19

func (l LogRequest) AddRequestEvent(c webFramework.WebFramework, branch, method, logText string, req RequestPtr)

func (LogRequest) AddRequestLog added in v0.11.19

func (l LogRequest) AddRequestLog(method, logText string, req RequestPtr)

func (LogRequest) CheckDuplicateRequest added in v0.11.19

func (l LogRequest) CheckDuplicateRequest(request RequestPtr) response.ErrorState

func (LogRequest) InitRequest added in v0.11.19

func (l LogRequest) InitRequest(c webFramework.WebFramework, method, url string) response.ErrorState

func (LogRequest) Initialize added in v0.11.19

func (l LogRequest) Initialize(c webFramework.WebFramework, method, url string, req RequestPtr, args ...any) (int, map[string]string, response.ErrorState)

func (LogRequest) InitializeNoLog added in v0.11.19

func (l LogRequest) InitializeNoLog(c webFramework.WebFramework, method, url string, req RequestPtr, args ...any) (int, map[string]string, response.ErrorState)

func (LogRequest) InsertRequest added in v0.11.19

func (l LogRequest) InsertRequest(req RequestPtr) response.ErrorState

func (LogRequest) LogEnd added in v0.11.19

func (l LogRequest) LogEnd(method, logText string, req RequestPtr)

func (LogRequest) LogStart added in v0.11.19

func (l LogRequest) LogStart(w webFramework.WebFramework, method, logText string) RequestPtr

func (LogRequest) UpdateRequestWithContext added in v0.11.19

func (l LogRequest) UpdateRequestWithContext(ctx context.Context, req RequestPtr) response.ErrorState

type LoggerInterface added in v0.3.0

type LoggerInterface interface {
	GetLogPath() string
	GetLogSize() int
	GetLogCompress() bool
	GetSkipPaths() []string
	GetHeaderName() string
}

type PaginationData added in v0.10.29

type PaginationData struct {
	Start   int    `form:"_start" query:"_start" validate:"omitempty"`
	End     int    `form:"_end" query:"_end" validate:"omitempty"`
	Filters string `form:"_filters" query:"_filters" validate:"omitempty"`
	Sort    string `form:"_sort" query:"_sort" validate:"omitempty"`
	Order   string `form:"_order" query:"_order" validate:"omitempty,oneof=asc desc"`
}

type Request

type Request struct {
	Header     webFramework.HeaderInterface `json:"header"`
	Id         string                       `json:"id"`
	RequestId  string                       `json:"request_id"`
	Time       time.Time                    `json:"dt"`
	Incoming   any                          `json:"incoming"`
	NationalId string                       `json:"national_id"`
	UrlPath    string                       `json:"url_path"`
	ServiceId  string                       `json:"service_id"`
	ActionId   string                       `json:"action_id"`
	BankId     string                       `json:"bank_id"`
	BranchId   string                       `json:"branch_id"`
	PersonId   string                       `json:"person_id"`
	UserId     string                       `json:"user_id"`
	Req        string                       `json:"req"`
	Resp       string                       `json:"resp"`
	Outgoing   any                          `json:"outgoing"`
	Result     string                       `json:"result"`
	Events     []EventData                  `json:"events"`
}

type RequestHeader

type RequestHeader struct {
	RequestId string `header:"Request-Id" reqHeader:"Request-Id" validate:"required,min=10,max=64"`
	Program   string `header:"Program-Id" reqHeader:"Program-Id"`
	Module    string `header:"Module-Id"  reqHeader:"Module-Id"`
	Method    string `header:"Method-Id"  reqHeader:"Method-Id"`
	User      string `header:"User-Id"    reqHeader:"User-Id"`
	Branch    string `header:"Branch-Id"  reqHeader:"Branch-Id"`
	Bank      string `header:"Bank-Id"    reqHeader:"Bank-Id"`
	Person    string `header:"Person-Id"  reqHeader:"Person-Id"`
}

func ParseRequest added in v0.9.0

func ParseRequest[Req any](
	w webFramework.WebFramework,
	mode Type,
	validateHeader bool,
) (*Req, *RequestHeader, response.ErrorState)

func (RequestHeader) GetBank added in v0.4.7

func (r RequestHeader) GetBank() string

func (RequestHeader) GetBranch added in v0.4.7

func (r RequestHeader) GetBranch() string

func (RequestHeader) GetId added in v0.2.0

func (r RequestHeader) GetId() string

func (RequestHeader) GetMethod added in v0.2.0

func (r RequestHeader) GetMethod() string

func (RequestHeader) GetModule added in v0.2.0

func (r RequestHeader) GetModule() string

func (RequestHeader) GetPerson added in v0.4.7

func (r RequestHeader) GetPerson() string

func (RequestHeader) GetProgram added in v0.2.0

func (r RequestHeader) GetProgram() string

func (RequestHeader) GetUser added in v0.2.0

func (r RequestHeader) GetUser() string

func (*RequestHeader) SetBank added in v0.4.7

func (r *RequestHeader) SetBank(bank string)

func (*RequestHeader) SetBranch added in v0.4.7

func (r *RequestHeader) SetBranch(branch string)

func (*RequestHeader) SetMethod added in v0.2.0

func (r *RequestHeader) SetMethod(method string)

func (*RequestHeader) SetModule added in v0.2.0

func (r *RequestHeader) SetModule(module string)

func (*RequestHeader) SetPerson added in v0.4.7

func (r *RequestHeader) SetPerson(person string)

func (*RequestHeader) SetProgram added in v0.2.0

func (r *RequestHeader) SetProgram(program string)

func (*RequestHeader) SetUser added in v0.2.0

func (r *RequestHeader) SetUser(user string)

type RequestInterface

type RequestInterface interface {
	Initialize(c webFramework.WebFramework, method, url string, req RequestPtr, args ...any) (int, map[string]string, response.ErrorState)
	InitRequest(c webFramework.WebFramework, method, url string) response.ErrorState
	InitializeNoLog(c webFramework.WebFramework, method, url string, req RequestPtr, args ...any) (int, map[string]string, response.ErrorState)
	AddRequestLog(method, log string, req RequestPtr)
	LogEnd(method, log string, req RequestPtr)
	AddRequestEvent(c webFramework.WebFramework, branch, method, log string, req RequestPtr)
	LogStart(c webFramework.WebFramework, method, log string) RequestPtr
	InsertRequest(request RequestPtr) response.ErrorState
	CheckDuplicateRequest(request RequestPtr) response.ErrorState
	UpdateRequestWithContext(ctx context.Context, request RequestPtr) response.ErrorState
}

type RequestModel

type RequestModel struct {
	QueryInterface libQuery.QueryRunnerInterface
	InsertInDb     string
	UpdateInDb     string
	QueryInDb      string
}

func (RequestModel) AddLogEvent

func (m RequestModel) AddLogEvent(method, log string, req RequestPtr)

func (RequestModel) AddRequestEvent

func (m RequestModel) AddRequestEvent(w webFramework.WebFramework, branch, method, log string, req RequestPtr)

func (RequestModel) AddRequestLog

func (m RequestModel) AddRequestLog(method, log string, req RequestPtr)

func (RequestModel) CheckDuplicateRequest

func (m RequestModel) CheckDuplicateRequest(request RequestPtr) response.ErrorState

func (RequestModel) InitRequest added in v0.9.1

func (m RequestModel) InitRequest(w webFramework.WebFramework, method, url string) response.ErrorState

func (RequestModel) Initialize

func (m RequestModel) Initialize(w webFramework.WebFramework, method, url string, req RequestPtr, args ...any) (int, map[string]string, response.ErrorState)

func (RequestModel) InitializeNoLog

func (m RequestModel) InitializeNoLog(c webFramework.WebFramework, method, url string, req RequestPtr, args ...any) (int, map[string]string, response.ErrorState)

func (RequestModel) InsertRequest

func (m RequestModel) InsertRequest(request RequestPtr) response.ErrorState

func (RequestModel) InsertRequestWithContext added in v0.6.10

func (m RequestModel) InsertRequestWithContext(ctx context.Context, request RequestPtr) response.ErrorState

func (RequestModel) LogEnd

func (m RequestModel) LogEnd(method, log string, r RequestPtr)

func (RequestModel) LogStart

func (m RequestModel) LogStart(w webFramework.WebFramework, method, log string) RequestPtr

func (RequestModel) UpdateRequest

func (m RequestModel) UpdateRequest(request RequestPtr) response.ErrorState

func (RequestModel) UpdateRequestWithContext added in v0.6.10

func (m RequestModel) UpdateRequestWithContext(ctx context.Context, request RequestPtr) response.ErrorState

type RequestPtr added in v0.9.0

type RequestPtr *Request

func GetRequest

func GetRequest[Q any](ctx webFramework.WebFramework, isJson bool) (int, string, []response.ErrorResponse, Q, RequestPtr, error)

func Req added in v0.2.0

func Req[Req any, Header any, PT interface {
	webFramework.HeaderInterface
	*Header
}](w webFramework.WebFramework, mode Type, validateHeader bool) (int, string, []response.ErrorResponse, Req, RequestPtr, response.ErrorState)

type Type added in v0.5.7

type Type int
const (
	NoBinding Type = iota
	JSON
	JSONWithURI
	Query
	QueryWithURI
	QueryWithPagination
	URI
	URIAndPagination
)

func TypeString added in v0.5.7

func TypeString(s string) (Type, error)

TypeString retrieves an enum value from the enum constants string name. Throws an error if the param is not part of the enum.

func TypeValues added in v0.5.7

func TypeValues() []Type

TypeValues returns all values of the enum

func (Type) IsAType added in v0.5.7

func (i Type) IsAType() bool

IsAType returns "true" if the value is listed in the enum definition. "false" otherwise

func (Type) MarshalJSON added in v0.5.7

func (i Type) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface for Type

func (Type) String added in v0.5.7

func (i Type) String() string

func (*Type) UnmarshalJSON added in v0.5.7

func (i *Type) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface for Type

Jump to

Keyboard shortcuts

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