apiserver

package
v0.0.0-...-dfe2c77 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2025 License: MIT Imports: 32 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// GinServerMode represents the Gin server mode
	// -> HTTP
	GinServerMode = "gin"
	// GRPCServerMode represents the gRPC server mode
	// -> gRPC
	GRPCServerMode = "grpc"
	// GRPCGatewayServerMode represents the gRPC gateway server mode
	// -> gRPC + HTTP
	GRPCGatewayServerMode = "grpc-gateway"
)

Variables

This section is empty.

Functions

func InstallGenericAPI

func InstallGenericAPI(engine *gin.Engine)

func NewAuthnWhiteListMatcher

func NewAuthnWhiteListMatcher() selector.Matcher

NewAuthnWhiteListMatcher creates a new AuthnWhiteListMatcher for the gRPC server.

func NewAuthzWhiteListMatcher

func NewAuthzWhiteListMatcher() selector.Matcher

NewAuthzWhiteListMatcher creates a new AuthzWhiteListMatcher for the gRPC server.

Types

type Config

type Config struct {
	ServerMode    string
	JWTKey        string
	JWTExpiryTime time.Duration
	GRPCOptions   *genericoptions.GRPCOptions
	TLSOptions    *genericoptions.TLSOptions
	HTTPOptions   *genericoptions.HTTPOptions
	MySQLOptions  *genericoptions.MySQLOptions
}

Config configuration structure, used to store application-related configurations. viper.Get is not used because this way can make it clearer to know which configuration items the application provides.

func (*Config) NewDB

func (cfg *Config) NewDB() (*gorm.DB, error)

func (*Config) NewServerConfig

func (cfg *Config) NewServerConfig() (*ServerConfig, error)

func (*Config) NewUnionServer

func (cfg *Config) NewUnionServer() (*UnionServer, error)

NewUnionServer creates a new UnionServer instance with the provided configuration.

type ServerConfig

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

func (*ServerConfig) InstallRESTAPI

func (s *ServerConfig) InstallRESTAPI(engine *gin.Engine)

func (*ServerConfig) NewGRPCServerOr

func (c *ServerConfig) NewGRPCServerOr() (server.Server, error)

NewGRPCServerOr create and initialize the gRPC or gRPC + GRPC-Gateway server. In the development of Go projects, the "Or" in the function name NewGRPCServerOr is generally used to represent the meaning of "or". Usually implies that the function will choose one possibility among two or more options. The specific meaning needs to be combined with the implementation of the function or understand it in the context. The following are some possible explanations: 1. Offer multiple construction method options 2. Handle default values or fallback logic 3. Express flexible options

func (*ServerConfig) NewGinServer

func (s *ServerConfig) NewGinServer() server.Server

type UnionServer

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

UnionServer defines a union server. Determine the type of server to be started based on ServerMode.

Federated servers are divided into the following two major categories: 1. Gin server: A standard REST server created by the Gin framework. Depending on whether TLS is enabled or not To determine whether to start HTTP or HTTPS; 2. GRPC server: A standard RPC server created by the gRPC framework 3. HTTP Reverse Proxy server: An HTTP reverse proxy server created by the grpc-gateway framework. Determine whether to start HTTP or HTTPS based on whether TLS is enabled;

The HTTP reverse proxy server relies on the gRPC server. Therefore, when starting the HTTP reverse proxy server, the gRPC server will be started first.

func (*UnionServer) Run

func (s *UnionServer) Run() error

Run starts the server based on the configuration.

type UserRetriever

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

UserRetriever is a struct that implements the UserRetriever interface.

func (*UserRetriever) GetUser

func (r *UserRetriever) GetUser(ctx context.Context, userID string) (*model.UserM, error)

Directories

Path Synopsis
biz
handler

Jump to

Keyboard shortcuts

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