go_ztm

package module
v0.1.0-beta.10 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2024 License: MIT Imports: 20 Imported by: 0

README

go-ztm | Microservices Framework for GoLang

PkgGoDev

go-ztm is a simple open-source framework written in golang that promotes an easy to develop microservices architecture.

Documentation

How to use

Examples

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddUSEService

func AddUSEService(u *Service) gin.HandlerFunc

func ConvertToInt

func ConvertToInt(u interface{}, ernVal int) int

func InitServiceSJWT

func InitServiceSJWT(c *gin.Context) (*SJWTClaims, *Service, bool)

func RandomString

func RandomString(n int) string

func UnmashalBody

func UnmashalBody(body io.ReadCloser) map[string]interface{}

Types

type ErrorMsg

type ErrorMsg struct {
	ErrorCode string `json:"code"`
	Message   string `json:"message"`
}

type SJWTClaims

type SJWTClaims struct {
	Auth    bool   `json:"auth"`
	UserId  int    `json:"userid"`
	Role    int    `json:"role"`
	Service string `json:"service"`
	Hop     int    `json:"hop"`
	SysAdm  bool   `json:"sysadm"`
}

type Service

type Service struct {
	UJwt        *aJWT.AuthJWT
	SJwt        *aJWT.AuthJWT
	Config      *ServiceConfiguration
	Database    *gorm.DB
	Rdb         *redis.Client
	ServicesSts []ServicesStatus
	// contains filtered or unexported fields
}

func (*Service) ClearUserNonceFromAll

func (u *Service) ClearUserNonceFromAll(userId int) bool

func (*Service) CompareUserNonce

func (u *Service) CompareUserNonce(userId int, nonce string) bool

func (*Service) DeleteUserNonceFromDB

func (u *Service) DeleteUserNonceFromDB(userId int) bool

func (*Service) GWRequest

func (u *Service) GWRequest(url string, method string, header http.Header, body io.ReadCloser, claims SJWTClaims) (*http.Response, error)

func (*Service) Initialize

func (u *Service) Initialize(cfgpath string) bool

func (*Service) IsUserAdmin

func (u *Service) IsUserAdmin(claims *UJWTClaims) bool

func (*Service) IssueNewUserJWT

func (u *Service) IssueNewUserJWT(claims UJWTClaims) (string, bool)

func (*Service) RefreshUserNonceFromAll

func (u *Service) RefreshUserNonceFromAll(userId int) bool

func (*Service) ReloadUserNonceFromDB

func (u *Service) ReloadUserNonceFromDB(userId int, userNonce string) bool

func (*Service) Request

func (u *Service) Request(path string, method string, header http.Header, body io.ReadCloser) (*http.Response, error)

func (*Service) RequestForwarder

func (u *Service) RequestForwarder(c *gin.Context)

func (*Service) RequestWithClaims

func (u *Service) RequestWithClaims(path string, method string, header http.Header, body io.ReadCloser, claims SJWTClaims) (*http.Response, error)

func (*Service) SRVRequest

func (u *Service) SRVRequest(path string, method string, header http.Header, body io.ReadCloser, claims SJWTClaims) (*http.Response, error)

func (*Service) SaveConfiguration

func (u *Service) SaveConfiguration() bool

func (*Service) Start

func (u *Service) Start(router *gin.Engine)

func (*Service) UpdateUserNonce

func (u *Service) UpdateUserNonce(userId int, userNonce string) bool

func (*Service) ValidateServiceJWT

func (u *Service) ValidateServiceJWT(r *http.Request) *SJWTClaims

func (*Service) ValidateUserJWT

func (u *Service) ValidateUserJWT(r *http.Request) *UJWTClaims

type ServiceConfiguration

type ServiceConfiguration struct {
	Ims            imsConfiguration
	Secrets        []serviceConfigurationJWT
	Database       serviceConfigurationDatabase
	RedisDB        serviceConfigurationRedisDB
	Gateways       []serviceConfigurationGateway
	AuthThirdParty []serviceConfigurationLoginThirdParty
	PathAuth       serviceConfigurationAuth
	PathRegister   serviceConfigurationRegister
	PathNonce      serviceConfigurationNonce
	PathAdmin      serviceConfigurationAdmin
	Services       []serviceConfigurationService
}

func (*ServiceConfiguration) AddService

func (u *ServiceConfiguration) AddService(name string, host string, port int, url string)

func (*ServiceConfiguration) Load

func (u *ServiceConfiguration) Load(dbconfig string) bool

func (*ServiceConfiguration) RemoveService

func (u *ServiceConfiguration) RemoveService(name string)

type ServicesStatus

type ServicesStatus struct {
	Name     string
	IsAlive  bool
	Services []map[string]any
}

type UJWTClaims

type UJWTClaims struct {
	Auth   bool   `json:"a"`
	UserId int    `json:"u"`
	Role   int    `json:"r"`
	SysAdm bool   `json:"s"`
	Nonce  string `json:"n"`
}

type UJWTClaimsMinimal

type UJWTClaimsMinimal struct {
	A bool   `json:"a"`
	U int    `json:"u"`
	R int    `json:"r"`
	S bool   `json:"s"`
	N string `json:"n"`
}

Jump to

Keyboard shortcuts

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