spec

package
v1.0.0-rc Latest Latest
Warning

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

Go to latest
Published: May 24, 2021 License: AGPL-3.0 Imports: 12 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIs

type APIs []Spec

func (APIs) Find

func (o APIs) Find(req *http.Request) *Spec

TODO: add cache

func (APIs) FindOriginPath

func (o APIs) FindOriginPath(req *http.Request) *Spec

type AuditContext

type AuditContext struct {
	UrlParams map[string]string
	UserID    string
	OrgID     int64
	Request   *http.Request
	Response  *http.Response
	Bundle    *bundle.Bundle
	BeginTime time.Time
	EndTime   time.Time
	Result    apistructs.Result
	ClientIP  string
	UserAgent string
	Cache     *sync.Map
}

func (*AuditContext) BindRequestData

func (ctx *AuditContext) BindRequestData(body interface{}) error

func (*AuditContext) BindResponseData

func (ctx *AuditContext) BindResponseData(body interface{}) error

func (*AuditContext) CreateAudit

func (ctx *AuditContext) CreateAudit(audit *apistructs.Audit) error

CreateAudit 创建审计事件

func (*AuditContext) GetApp

func (ctx *AuditContext) GetApp(idObject interface{}) (*apistructs.ApplicationDTO, error)

func (*AuditContext) GetOrg

func (ctx *AuditContext) GetOrg(idObject interface{}) (*apistructs.OrgDTO, error)

func (*AuditContext) GetParamInt64

func (ctx *AuditContext) GetParamInt64(key string) (int64, error)

func (*AuditContext) GetParamString

func (ctx *AuditContext) GetParamString(key string) (string, error)

func (*AuditContext) GetParamUInt64

func (ctx *AuditContext) GetParamUInt64(key string) (uint64, error)

func (*AuditContext) GetProject

func (ctx *AuditContext) GetProject(idObject interface{}) (*apistructs.ProjectDTO, error)

type Matcher

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

func NewMatcher

func NewMatcher(spec *Spec) *Matcher

func (*Matcher) MatchBackendPath

func (m *Matcher) MatchBackendPath(path string) bool

func (*Matcher) MatchMethod

func (m *Matcher) MatchMethod(method string) bool

func (*Matcher) MatchPath

func (m *Matcher) MatchPath(path string) bool

type Path

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

func NewPath

func NewPath(path string) *Path

func (*Path) Fill

func (p *Path) Fill(vars map[string]string) string

func (*Path) Match

func (p *Path) Match(realPath string) bool

func (*Path) String

func (p *Path) String() string

func (*Path) Vars

func (p *Path) Vars(realPath string) map[string]string

type Scheme

type Scheme int
const (
	WS Scheme = iota
	HTTP
)

func SchemeFromString

func SchemeFromString(s string) (Scheme, error)

func (Scheme) String

func (t Scheme) String() string

type Spec

type Spec struct {
	Path            *Path
	BackendPath     *Path
	Host            string
	Scheme          Scheme
	Method          string
	Custom          func(rw http.ResponseWriter, req *http.Request)
	CustomResponse  func(*http.Response) error
	Audit           func(*AuditContext) error
	NeedDesensitize bool // 是否需要对返回的 userinfo 进行脱敏处理,id也会被脱敏
	CheckLogin      bool
	TryCheckLogin   bool // 和CheckLogin区别为如果不登录也会通过,只是没有user-id
	CheckToken      bool
	CheckBasicAuth  bool
	ChunkAPI        bool
	// `Host` 是API原始配置
	// 分别转化为 marathon 和 k8s 的host
	MarathonHost string
	K8SHost      string
	Port         int
}

func (*Spec) Validate

func (s *Spec) Validate() error

Jump to

Keyboard shortcuts

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