server

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2026 License: MIT Imports: 15 Imported by: 0 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

Overview

Package server 的 cookie interceptor。

从 gRPC metadata 提取上游网易云 cookie(x-netease-cookie), 调 engine.WithCookie 注入 context。凭证出域——cookie 不进 proto 字段, 由 interceptor 统一从 metadata 提取,service 对 cookie 来源透明。

REST 调用方经 grpc-gateway 传 "Grpc-Metadata-X-Netease-Cookie" header, gateway 自动桥接到 metadata key "x-netease-cookie"(前缀剥离)。

Package server 装配 gRPC server 与 grpc-gateway runtime mux。

gRPC server 监听 gRPC 端口对外提供强类型 RPC;gateway runtime mux 监听 HTTP 端口, 通过 dial 连本地 gRPC server,把 REST 请求转成 gRPC 调用。这是双 server 标准架构: 跨语言调用方走 gRPC,curl/Postman/前端走 gateway 暴露的 REST。

地基阶段(issue 0001):service 全部注册为 unimplemented 占位,只保证 server 能启动、 grpcurl 能 reflection 连上。真实接口实现在 issue 0005 迁移 15 接口时填入。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CookieInterceptor

func CookieInterceptor(ctx context.Context, req any, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (any, error)

CookieInterceptor 从 incoming metadata 提取网易云 cookie,注入 context。

无 metadata 或无 cookie key 时注入空字符串——engine 据此走 session 池选取。

Types

type App

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

App 持有 gRPC server 与 gateway HTTP server,统一管理生命周期。

func NewApp

func NewApp(grpcAddr, httpAddr string, eng *engine.Engine, sessions session.SessionStore) (*App, error)

NewApp 创建双 server 应用,注入 engine 和 session 池装配真实 service impl。

func (*App) Shutdown

func (a *App) Shutdown(ctx context.Context) error

Shutdown 优雅关闭 gRPC server 与 gateway HTTP server。

Jump to

Keyboard shortcuts

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