csweb

package module
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2024 License: MIT Imports: 14 Imported by: 0

README

csweb

Being the cornerstone framework of the web for golang

Characteristic

  1. provides HTTP and GRPC serve
  2. validator
  3. metrics (prometheus)
  4. tracer (zipkin)
  5. log with traceID
  6. tools library (gorm/jwt/seata...)
  7. jwt Auth
  8. recovery
  9. ratelimit
  10. error handle

TODO List

  1. Docker/Makefile
  2. service discovery
  3. goroutine pool
  4. auto generate infrastructure code
  5. cache (redis)
  6. pub/sub
  7. cron
  8. config center (apollo)
  9. project template

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Cors added in v0.0.3

func Cors(handler http.Handler) http.Handler

Types

type App

type App struct {
	Name string
	Addr string

	Serve ServeInterface
	// contains filtered or unexported fields
}

func NewApp

func NewApp(name string, options ...ServeOptions) *App

NewApp new an app with name

func (*App) InitServe

func (that *App) InitServe(s ServeInterface)

InitServe init the http serve and grpc serve

func (*App) Run

func (that *App) Run(addr string) error

type Options

type Options struct {
	Gateway       string
	TraceAddr     string
	EnableMetrics bool
	MetricsAddr   string
	JwtSignKey    string

	RateLimit int
	// contains filtered or unexported fields
}

type ServeInterface

type ServeInterface interface {
	GRPCServe(s *grpc.Server) error
	HTTPServe(mux *runtime.ServeMux, opts []grpc.DialOption) error
}

type ServeOptions

type ServeOptions func(opts *Options)

func WithGateway

func WithGateway(addr string) ServeOptions

WithGateway enable the gateway and specify the address

func WithJwtAuth

func WithJwtAuth(signKey string, authFilterMethods ...string) ServeOptions

func WithMetrics

func WithMetrics(addr string) ServeOptions

func WithRateLimit

func WithRateLimit(num int) ServeOptions

func WithTracer

func WithTracer(addr string) ServeOptions

Directories

Path Synopsis
pkg
protos

Jump to

Keyboard shortcuts

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