server

package
v0.0.1-beta.5 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2026 License: AGPL-3.0 Imports: 17 Imported by: 0

Documentation

Overview

Package server 装配 chi 路由:/api/admin/*(静态 token OR platform_admin JWT)+ /api/user/*(JWT 保护,register/login 公开)+ 三个 AI 端点 + /healthz。 架构约束:所有 API 统一收口于 /api/*,前端 SPA 占用根及 /api/user/*、/app/*, 两者无前缀重叠,SPA fallback 可无歧义地回 index.html。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func UserIDFromContext

func UserIDFromContext(ctx context.Context) (int64, bool)

UserIDFromContext 取 /admin JWT 鉴权路径注入的用户 id(兑换码生成 created_by 用);静态 admin token 路径未注入 → (0, false)。

Types

type Options

type Options struct {
	AdminToken        string
	JWTIssuer         *auth.Issuer            // platform_admin JWT 鉴权(/api/admin 扩展)
	UserStatus        auth.UserStatusProvider // 用户快照 status+role(JWT 鉴权路径禁用/降权即拒;nil = JWT 路径全拒)
	MaxInflight       int64
	ReadHeaderTimeout time.Duration
	MaxHeaderBytes    int
	AdminHandler      http.Handler // 已挂 /api/admin/* 路由
	UserHandler       http.Handler // 已挂 /api/user/* 路由(内部完成公开/JWT 分流)
	AIHandler         http.Handler // proxy 三个端点
	WebFS             fs.FS        // 前端构建产物(nil = 不挂静态资源)
	Logger            *logx.Logger
}

type Server

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

func NewServer

func NewServer(opts Options) *Server

func (*Server) Handler

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

Jump to

Keyboard shortcuts

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