代码拉取完成,页面将自动刷新
同步操作将从 bfbd/wechat-proxy 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
package main
import (
"flag"
"fmt"
"io/ioutil"
"log"
"net/http"
"wechat-proxy/enterprise"
"wechat-proxy/wechat"
"wechat-proxy/wrap"
)
func main() {
wrapHandlers()
wechatHandlers()
enterpriseHandlers()
http.Handle("/example/", http.StripPrefix("/example/", http.FileServer(http.Dir("./example"))))
http.HandleFunc("/echo", func(w http.ResponseWriter, r *http.Request) {
defer r.Body.Close()
body, err := ioutil.ReadAll(r.Body)
if err != nil {
w.Write([]byte(err.Error()))
return
}
w.Write(body)
log.Println(string(body))
})
host, port, tls := parseArgs()
address := fmt.Sprintf("%s:%d", host, port)
fmt.Printf("wechat proxy starting at %q ...\n", address)
if tls {
log.Fatal(http.ListenAndServeTLS(address, "wxproxy.crt", "wxproxy.key", nil))
} else {
log.Fatal(http.ListenAndServe(address, nil))
}
}
func parseArgs() (host string, port uint, tls bool) {
flag.UintVar(&port, "port", 8080, "Listening port.")
flag.UintVar(&port, "p", 8080, "Listening port.")
flag.BoolVar(&tls, "tls", false, "Https scheme.")
flag.Parse()
return
}
func wrapHandlers() {
// /register?key=...&appid=...&secret=...
// &token=&aes=
// &mch_id=&mch_key=&server_ip=
// &expires=&call=/msg&call=/api&call=
http.Handle("/register", wrap.NewRegisterServer())
// /app/<key>/api
// /app/<key>/msg?signature=...
// ...
http.Handle("/app/", wrap.NewWrapAppServer())
// /qrcode?path=...&size=
http.Handle("/qrcode", wrap.NewQrCodeServer())
// /short?path=...&expires=
// http.Handle("/short/", wrap.NewShortServer())
// /user
userServer := wrap.NewUserServer()
http.Handle("/user", userServer)
}
func wechatHandlers() {
// /api?appid=...&secret=...
// /api/new?appid=...&secret=...
apiServer := wechat.NewApiServer()
http.Handle("/api", apiServer)
http.Handle("/api/new", apiServer)
// /msg?token=...&aes=...&call=...&call=...&...
// /msg/json?token=...&aes=...&call=...&call=...&...
msgServer := wechat.NewMessageServer()
http.Handle("/msg", msgServer)
http.Handle("/msg/json", msgServer)
// /auth??appid=...&secret=...&call=...&state=&lang=
// /auth/info?appid=...&secret=...&call=...&state=&lang=
authServer := wechat.NewAuthServer()
http.Handle("/auth", authServer) // get openid & unionid
http.Handle("/auth/info", authServer) // get user info
payServer := wechat.NewPayServer()
http.Handle("/pay", payServer)
// /pay/qrcode?
// &appid=...&mch_id=...&mch_key=...&server_ip=...
// &fee=...&name=&call=&...
http.Handle("/pay/qrcode", payServer)
// /pay/js?
// &appid=...&mch_id=...&mch_key=...&server_ip=...
// &openid=...&fee=...&name=&call=&...
http.Handle("/pay/js", payServer)
// /jsapi?appid=...&secret=...
// /jsapi?access_token=...
http.Handle("/jsapi", wechat.NewJsTicketServer())
// /js/config?appid=...&secret=...&debug=&apilist=
http.Handle("/js/config", wechat.NewJsConfigServer())
http.Handle("/js/card", wechat.NewCardServer())
}
func enterpriseHandlers() {
// /qyapi?corpid=...&corpsecret=...
// /qyapi/new?corpid=...&corpsecret=...
qyServer := enterprise.NewQyServer()
http.Handle("/qyapi", qyServer)
http.Handle("/qyapi/new", qyServer)
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。