Documentation ¶
Index ¶
- Variables
- func CheckPasswordHash(password, hash string) bool
- func ConstructKey(prefix, key string) string
- func CorsMiddleware() gin.HandlerFunc
- func ExtractToken(r *http.Request) string
- func ExtractTokenFromHeader(r *http.Request) string
- func GetEnv(key, fallback string) string
- func GetPageNumber(page string) int
- func GetServerAddrs(addrs string) []string
- func HashPassword(password string) (string, error)
- func InitLogger(mode string)
- func InitializeGrpcClient(svcHost string) (*grpc.ClientConn, error)
- func InitializeGrpcServer(logger GrpcLogger) *grpc.Server
- func IsValidEmail(email string) bool
- func Join(strs ...string) string
- func LogTraceUnary() grpc.UnaryServerInterceptor
- func LoggingMiddleware(logger HttpLogger) gin.HandlerFunc
- func MaxAllowed(n int64) gin.HandlerFunc
- func NewGrpcEndpoint(conn *grpc.ClientConn, serviceID, serviceName, method string, ...) endpoint.Endpoint
- func ParseTimeYMD(value string) *time.Time
- func ResponseError(c *gin.Context, httpCode int, err error)
- func StringToStringValue(value *string) *wrapperspb.StringValue
- func StringValueToString(value *wrapperspb.StringValue) *string
- func TimeToYMDStringValue(t *time.Time) *wrapperspb.StringValue
- func TokenAuthMiddleware(secret string) gin.HandlerFunc
- func TokenValid(tokenString string, secret string) error
- func VerifyToken(tokenString string, secret string) (*jwt.Token, error)
- type AccessDetails
- type Closer
- type ErrResponse
- type GrpcLogger
- type GrpcServer
- type HttpLogger
- type HttpServer
- type IDGenerator
- type Migrator
- type Pagination
- type Runner
- type Server
- type SuccessPagingResponse
- type SuccessResponse
- type TokenDetails
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrInvalidParam = errors.New("invalid parameter") ErrServer = errors.New("server error") )
View Source
var ( JWTAuthHeader = "Authorization" JaegerHeader = "Trace-Id" )
View Source
var (
DefaultLimit int64 = 20
)
View Source
var (
ServiceIdHeader string = "Service-Id"
)
Functions ¶
func CheckPasswordHash ¶ added in v0.1.10
func ConstructKey ¶
func CorsMiddleware ¶
func CorsMiddleware() gin.HandlerFunc
func ExtractToken ¶ added in v0.1.14
func ExtractTokenFromHeader ¶
func GetPageNumber ¶
func GetServerAddrs ¶
func HashPassword ¶ added in v0.1.10
func InitLogger ¶
func InitLogger(mode string)
func InitializeGrpcClient ¶ added in v0.1.7
func InitializeGrpcClient(svcHost string) (*grpc.ClientConn, error)
func InitializeGrpcServer ¶ added in v0.1.7
func InitializeGrpcServer(logger GrpcLogger) *grpc.Server
func IsValidEmail ¶ added in v0.1.11
func LogTraceUnary ¶ added in v0.1.7
func LogTraceUnary() grpc.UnaryServerInterceptor
LogTraceUnary logs trace id from the incoming request context
func LoggingMiddleware ¶
func LoggingMiddleware(logger HttpLogger) gin.HandlerFunc
func MaxAllowed ¶
func MaxAllowed(n int64) gin.HandlerFunc
func NewGrpcEndpoint ¶ added in v0.1.7
func NewGrpcEndpoint(conn *grpc.ClientConn, serviceID, serviceName, method string, grpcReply interface{}) endpoint.Endpoint
func ParseTimeYMD ¶ added in v0.1.12
func StringToStringValue ¶ added in v0.1.11
func StringToStringValue(value *string) *wrapperspb.StringValue
func StringValueToString ¶ added in v0.1.13
func StringValueToString(value *wrapperspb.StringValue) *string
func TimeToYMDStringValue ¶ added in v0.1.14
func TimeToYMDStringValue(t *time.Time) *wrapperspb.StringValue
func TokenAuthMiddleware ¶ added in v0.1.14
func TokenAuthMiddleware(secret string) gin.HandlerFunc
func TokenValid ¶ added in v0.1.14
Types ¶
type AccessDetails ¶ added in v0.1.15
func ExtractRefreshTokenMetadata ¶ added in v0.1.16
func ExtractRefreshTokenMetadata(tokenString string, secret string) (AccessDetails, error)
func ExtractTokenMetadata ¶ added in v0.1.15
func ExtractTokenMetadata(tokenString string, secret string) (AccessDetails, error)
type ErrResponse ¶
type GrpcLogger ¶ added in v0.1.7
func NewGrpcLogger ¶ added in v0.1.7
func NewGrpcLogger() GrpcLogger
type GrpcServer ¶
type GrpcServer interface { Register() Run() GracefulShutdown() }
type HttpLogger ¶
func NewHttpLogger ¶
func NewHttpLogger() HttpLogger
type HttpServer ¶
type IDGenerator ¶
func NewIDGenerator ¶
func NewIDGenerator() (IDGenerator, error)
type Pagination ¶
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
func (*Server) GracefulShutdown ¶
type SuccessPagingResponse ¶
type SuccessPagingResponse[T any] struct { Success bool `json:"success" example:"true"` Data T `json:"data"` Pagination Pagination `json:"pagination"` }
type SuccessResponse ¶
type TokenDetails ¶ added in v0.1.14
type TokenDetails struct { AccessToken string RefreshToken string AccessUuid string RefreshUuid string AtExpires int64 RtExpires int64 }
func CreateToken ¶ added in v0.1.14
func CreateToken(userUuid string, atSecret, rtSecret string, atExpires, rtExpires int64) (TokenDetails, error)
Click to show internal directories.
Click to hide internal directories.