forked from btccom/btcpool-go-modules-ABANDONED
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHTTPAPI.go
41 lines (30 loc) · 817 Bytes
/
HTTPAPI.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package main
// #cgo CXXFLAGS: -std=c++11
// #include "UserListJSON.h"
import "C"
import (
"net/http"
"strconv"
"github.com/golang/glog"
)
// HTTPRequestHandle HTTP请求处理函数
type HTTPRequestHandle func(http.ResponseWriter, *http.Request)
// 启动 API Server
func runAPIServer() {
defer waitGroup.Done()
// HTTP监听
glog.Info("Listen HTTP ", configData.ListenAddr)
http.HandleFunc("/", getUserIDList)
err := http.ListenAndServe(configData.ListenAddr, nil)
if err != nil {
glog.Fatal("HTTP Listen Failed: ", err)
return
}
}
// getUserIDList 获取子账户列表
func getUserIDList(w http.ResponseWriter, req *http.Request) {
lastIDStr := req.FormValue("last_id")
lastID, _ := strconv.Atoi(lastIDStr)
json := C.GoString(C.getUserListJson(C.int(lastID)))
w.Write([]byte(json))
}