MCPcopy Create free account
hub / github.com/0xUnixIO/pulse / Register

Method Register

internal/payment/shop.go:101–107  ·  view source on GitHub ↗

Register registers shop routes on the given mux. These are PUBLIC endpoints (no auth required). shop/* 使用生产密钥(真实扣款),/shop-test/* 使用沙盒密钥。

(mux *http.ServeMux)

Source from the content-addressed store, hash-verified

99// These are PUBLIC endpoints (no auth required).
100// /shop/* 使用生产密钥(真实扣款),/shop-test/* 使用沙盒密钥。
101func (s *ShopAPI) Register(mux *http.ServeMux) {
102 s.checkoutLimiter = newCheckoutRateLimiter()
103 mux.HandleFunc("GET /shop/plans", s.listPlansHandler("live"))
104 mux.HandleFunc("POST /shop/checkout", s.createCheckoutHandler("live", "/shop"))
105 mux.HandleFunc("GET /shop-test/plans", s.requireAdmin(s.listPlansHandler("test")))
106 mux.HandleFunc("POST /shop-test/checkout", s.requireAdmin(s.createCheckoutHandler("test", "/shop-test")))
107}
108
109// requireAdmin 要求请求携带有效的管理员 Bearer token。
110func (s *ShopAPI) requireAdmin(next http.HandlerFunc) http.HandlerFunc {

Callers 1

RunFunction · 0.95

Calls 4

listPlansHandlerMethod · 0.95
createCheckoutHandlerMethod · 0.95
requireAdminMethod · 0.95
newCheckoutRateLimiterFunction · 0.85

Tested by

no test coverage detected