server

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Overview

Package server 把 vault 与 render 组装成 HTTP 服务。 本包不含业务逻辑,只做路由、参数校验与序列化。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Server

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

Server 持有各组件并暴露 HTTP 接口。

func New

func New(v vault.Vault, w vault.Writer, r *render.Renderer, g *auth.Guard, webFS fs.FS) *Server

New 构造 Server。webFS 是 embed 进来的前端资源文件系统。 w 为 nil 时整个 /api/edit/ 挂载点不存在,程序退化为只读阅读器,这是 唯一支持的 nil 配置。g 必须非 nil:/auth、/api/session 无条件挂载 (不像 /api/edit/ 那样受 w 是否为 nil 控制),两者都会直接解引用 g, 传 nil 会在请求到达时 panic,而不是退化成什么可用状态。

func (*Server) Handler

func (s *Server) Handler() http.Handler

Handler 返回可直接挂到 http.Server 上的处理器。

func (*Server) StartWatching

func (s *Server) StartWatching(ctx context.Context)

StartWatching 启动文件监听循环,把 vault 的变更广播给所有已连接的浏览器。 ctx 结束时循环退出。

Jump to

Keyboard shortcuts

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