apis

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var PRESALE_SURVEY = ApiSpec{
	Path:   "/api/survey/login",
	Scheme: "http",
	Method: "GET",
	Doc:    "summary: 售前调查 API(伪装成登录接口)",
	Custom: func(rw http.ResponseWriter, req *http.Request) {
		var d detail
		if err := validatePurveyDetail(&d, req.URL.Query()); err != nil {
			logrus.Errorf("failed to parse survey detail, err: %v", err)
			errorResp(rw)
			return
		}
		msg := apistructs.MessageCreateRequest{
			Sender: "survey",
			Labels: map[apistructs.MessageLabel]interface{}{
				apistructs.DingdingLabel: []apistructs.Target{{Receiver: conf.SurveyDingding(), Secret: ""}},
			},
			Content: makeDingdingMessage(d),
		}
		bdl := bundle.New(bundle.WithErdaServer())
		if err := bdl.CreateMessage(&msg); err != nil {
			logrus.Warnf("failed to POST survey, err: %v", err)
			errorResp(rw)
			return
		}
		successResp(rw)
	},
}

Functions

func NewSwagger

func NewSwagger(title string) *openapi3.Swagger

Types

type ApiSpec

type ApiSpec struct {
	Path        string
	BackendPath string
	Method      string
	Host        string
	// 正常情况下,使用 internal/pkg/innerdomain 能解析转换出 `Host` 对应的 marathonHost 和 k8sHost,
	// 但是,当 `Host` 中的地址是老版的 marathon 内部地址,那么就无法确定 k8s地址会是什么,需要用 `K8SHost` 显式指定
	// 比如以下地址就无法转换
	// "hepa-gateway-1.hepagateway.addon-hepa-gateway.v1.runtimes.marathon.l4lb.thisdcos.directory"
	K8SHost         string
	Scheme          string
	Custom          func(rw http.ResponseWriter, req *http.Request)
	CustomResponse  func(*http.Response) error // 如果是 websocket,没意义,在 generator 里检查
	Audit           func(ctx *spec.AuditContext) error
	NeedDesensitize bool // 是否需要对返回的 userinfo 进行脱敏处理
	CheckLogin      bool
	TryCheckLogin   bool
	CheckToken      bool
	CheckBasicAuth  bool
	ChunkAPI        bool
	Doc             string
	// API 请求 & 应答 类型, 定义在 apistructs
	RequestType  interface{}
	ResponseType interface{}
	// 是否为真正的openapi,会生成2份 swagger doc, 一份是只有openapi的,另一份有所有注册的API
	IsOpenAPI bool
	// API 分类, 默认为Path的第二部分 /a/b/c -> b
	Group string

	// Parameters describes the request and response parameters
	Parameters *Parameters
	// contains filtered or unexported fields
}

ApiSpec 转换成 openapi.api.Spec,方便用户写的类型

func (*ApiSpec) AddOperationTo

func (api *ApiSpec) AddOperationTo(v3 *openapi3.Swagger) error

AddOperationTo generates self as an *openapi3.Operation and add it to the *openapi3.Swagger

func (ApiSpec) Convert2AccessibleApi

func (api ApiSpec) Convert2AccessibleApi() apistructs.AccessibleAPI

Convert2AccessibleApi 直接从 openapi 定义生成 openapi oauth2 token 可访问的 api 格式

func (*ApiSpec) IsValidForOperation

func (api *ApiSpec) IsValidForOperation() bool

type Parameters

type Parameters struct {
	Tag         string
	Header      http.Header
	QueryValues url.Values
	Body        interface{}
	Response    interface{}
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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