api

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2024 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClientIP added in v0.1.7

func ClientIP(r *http.Request) string

func Cros added in v0.1.7

func Cros(w http.ResponseWriter, req *http.Request, headers ...map[string]string)

func E added in v0.1.6

func E(err error)

func MetaHost added in v0.1.8

func MetaHost(ctx context.Context) string

func MetaInt added in v0.1.8

func MetaInt(ctx context.Context, key string) int

func MetaIp added in v0.1.8

func MetaIp(ctx context.Context) string

func MetaMethod added in v0.1.8

func MetaMethod(ctx context.Context) string

func MetaString added in v0.1.8

func MetaString(ctx context.Context, key string) string

func MetaToken added in v0.1.8

func MetaToken(ctx context.Context) string

func Response

func Response(w http.ResponseWriter, code int, msg ...string)

func StargoHTTPError added in v0.1.8

func StargoHTTPError(ctx context.Context, mux *runtime.ServeMux, marshaler runtime.Marshaler, w http.ResponseWriter, r *http.Request, err error)

func Success

func Success(w http.ResponseWriter, msg ...string)

Types

type APIError added in v0.1.8

type APIError struct {
	Service string        `json:"service"`
	Method  string        `json:"method"`
	Code    string        `json:"code"`
	Msg     string        `json:"msg"`
	Details []interface{} `json:"details,omitempty"`
}

type Api added in v0.1.6

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

func NewApi added in v0.1.6

func NewApi(conf *Config) *Api

func (*Api) Conn added in v0.1.6

func (e *Api) Conn() *grpc.ClientConn

func (*Api) Ctx added in v0.1.6

func (e *Api) Ctx() context.Context

func (*Api) Rmux added in v0.1.6

func (e *Api) Rmux() *runtime.ServeMux

func (*Api) Run added in v0.1.6

func (e *Api) Run()

func (*Api) WrapperSwagger added in v0.1.8

func (e *Api) WrapperSwagger(mux *http.ServeMux)

type Config added in v0.1.3

type Config struct {
	App             string
	Port            string
	Registry        *naming.Config
	DiaOpts         []grpc.DialOption
	SwgFs           fs.FS
	Wrapper         func(http.Handler) http.Handler
	SwaggerRoute    string
	SwaggerUIPrefix string
	SMOpts          []runtime.ServeMuxOption
}

type Request

type Request struct {
	Data  RequestData
	Query url.Values
	// contains filtered or unexported fields
}

func NewRequest added in v0.1.8

func NewRequest(h http.Handler, w http.ResponseWriter, req *http.Request) *Request

func (*Request) Next

func (e *Request) Next()

func (*Request) NoAuth

func (e *Request) NoAuth(noAuth slice.Slice[string]) bool

过滤不需要验证的url

func (*Request) Pack

func (e *Request) Pack() *Request

解析完成之后会装req

func (*Request) Set

func (e *Request) Set(key, value string)

func (*Request) SetHeader added in v0.1.7

func (e *Request) SetHeader(keys []string)

[]string{"X-Estate-Id"} 设置header部分变量

func (*Request) Unpack

func (e *Request) Unpack() *Request

请求执行前打开请求

type RequestData

type RequestData map[string]any

func (RequestData) Set

func (e RequestData) Set(key string, value any) RequestData

Jump to

Keyboard shortcuts

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