run

package
v1.17.0 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2026 License: Apache-2.0 Imports: 37 Imported by: 1 module, 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

Overview

本文件提供匿名 OpenAPI HTTP 入口、内部兼容入口和 Swagger 静态资源挂载。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetInternalOpenApi

func GetInternalOpenApi(req *http.Request, services ...*router.ServiceRouter) interface{}

GetInternalOpenApi 返回完整业务文档,供内部兼容性检查和受保护的内部端点使用。

func GetInternalService

func GetInternalService[T any](key string) *T

func GetOpenApi

func GetOpenApi(req *http.Request, services ...*router.ServiceRouter) interface{}

GetOpenApi 返回可匿名访问的业务文档,不包含内部专用 Public 路由和调用方白名单。

func GetOpenApiSameOrigin

func GetOpenApiSameOrigin(req *http.Request, services ...*router.ServiceRouter) interface{}

GetOpenApiSameOrigin 返回开发期 HTMLServer 使用的同源业务文档。 它不改变正式 REST OpenAPI 的按服务监听端口语义。

func OpenAPIHandler

func OpenAPIHandler(service ...*router.ServiceRouter) (string, http.Handler)

OpenAPIHandler 返回匿名外部 OpenAPI 文档的挂载路径和处理器。

func SetInternalService

func SetInternalService[T any](key string, service *T) error

func SwaggerHandler

func SwaggerHandler() (string, http.FileSystem)

SwaggerHandler 返回 Swagger 静态资源的挂载路径和文件系统。

Types

type FiberServer

type FiberServer struct {
	Port int

	Parent *WebServer
	// contains filtered or unexported fields
}

func NewFiberServer

func NewFiberServer(port int) *FiberServer

func (*FiberServer) AddServiceRouter

func (own *FiberServer) AddServiceRouter(sr *router.ServiceRouter)

func (*FiberServer) Run

func (own *FiberServer) Run()

func (*FiberServer) Start

func (own *FiberServer) Start()

func (*FiberServer) Stop

func (own *FiberServer) Stop()

type HTMLServer

type HTMLServer struct {
	Port int

	Isstart chan bool
	Parent  *WebServer
	// contains filtered or unexported fields
}

func NewHTMLServer

func NewHTMLServer(port int) *HTMLServer

func (*HTMLServer) AddServiceRouter

func (own *HTMLServer) AddServiceRouter(sr *router.ServiceRouter)

func (*HTMLServer) Handler

func (own *HTMLServer) Handler() http.Handler

Handler 返回 Prepare 缓存的 Handler;未 Prepare 时返回 nil。

func (*HTMLServer) Prepare

func (own *HTMLServer) Prepare() error

Prepare 预构建并缓存完整 HTTP Handler(含同源认证代理、Public/Private、Manage 与 SPA)。 存在 Manage Auth 权威时必须解析四个固定路径;缺少 Router 时 fail closed。 所有精确 pattern 经 htmlMuxMount 登记,冲突 fail-closed,禁止 ServeMux panic。

func (*HTMLServer) SetManageAuthAuthority

func (own *HTMLServer) SetManageAuthAuthority(authority *manageAuthAuthority)

SetManageAuthAuthority 保存 Manage Auth 权威服务选择结果。

func (*HTMLServer) Start

func (own *HTMLServer) Start()

func (*HTMLServer) Stop

func (own *HTMLServer) Stop()

type WebBootstrap

type WebBootstrap struct {
	SchemaVersion int                     `json:"schema_version"`
	Auth          WebBootstrapAuth        `json:"auth"`
	Endpoints     WebBootstrapEndpoints   `json:"endpoints"`
	TestTokens    []WebBootstrapTestToken `json:"test_tokens"`
	UI            WebBootstrapUI          `json:"ui"`
}

WebBootstrap 是前端启动所需的公开运行时能力描述,不得包含密钥或 Token。

type WebBootstrapAuth

type WebBootstrapAuth struct {
	Mode             string `json:"mode"`
	Type             string `json:"type"`
	AuthorityService string `json:"authority_service"`
}

type WebBootstrapEndpoints

type WebBootstrapEndpoints struct {
	AcquireToken  *string `json:"acquire_token"`
	CasdoorConfig *string `json:"casdoor_config"`
	Callback      string  `json:"callback"`
	Refresh       string  `json:"refresh"`
	OpenAPI       string  `json:"openapi"`
}

type WebBootstrapTestToken

type WebBootstrapTestToken struct {
	Service      string `json:"service"`
	AcquireToken string `json:"acquire_token"`
}

type WebBootstrapUI

type WebBootstrapUI struct {
	ShowLogin        bool `json:"show_login"`
	ShowLogout       bool `json:"show_logout"`
	ShowTestIdentity bool `json:"show_test_identity"`
}

type WebServer

type WebServer struct {
	sync.RWMutex

	ViewPort int
	// ManageAuthAuthorityService 指定多业务服务开发视图的默认 Manage Auth 服务。
	// 单业务服务会自动选择;多个业务 Manage 服务必须显式指定统一权威。
	ManageAuthAuthorityService string
	Port                       int
	GRPCPort                   int
	// contains filtered or unexported fields
}

func NewWebServer

func NewWebServer() *WebServer

func (*WebServer) AddIService

func (own *WebServer) AddIService(service types.IService, option ...*types.ServerOption)

func (*WebServer) AddServiceContext

func (own *WebServer) AddServiceContext(sc *router.ServiceContext)

func (*WebServer) GetServerOption

func (own *WebServer) GetServerOption(name string) *types.ServerOption

func (*WebServer) GetServerOptions

func (own *WebServer) GetServerOptions() map[string]*types.ServerOption

func (*WebServer) SetOption

func (own *WebServer) SetOption(service types.IService, option *types.ServerOption)

func (*WebServer) Start

func (own *WebServer) Start()

func (*WebServer) Stop

func (own *WebServer) Stop()

Jump to

Keyboard shortcuts

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