forked from davyxu/cellnet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpeer_http.go
42 lines (32 loc) · 971 Bytes
/
peer_http.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
42
package cellnet
import (
"html/template"
"net/http"
)
type HTTPAcceptor interface {
GenericPeer
// 设置http文件服务虚拟地址和文件系统根目录
SetFileServe(dir string, root string)
// 设置模板文件地址
SetTemplateDir(dir string)
// 设置http模板的分隔符,解决默认{{ }}冲突问题
SetTemplateDelims(delimsLeft, delimsRight string)
// 设置模板的扩展名,默认: .tpl .html
SetTemplateExtensions(exts []string)
// 设置模板函数入口
SetTemplateFunc(f []template.FuncMap)
}
type HTTPRequest struct {
REQMsg interface{} // 请求消息, 指针
ACKMsg interface{} // 回应消息, 指针
REQCodecName string // 可为空, 默认为json格式
ACKCodecName string // 可为空, 默认为json格式
}
// HTTP连接器接口
type HTTPConnector interface {
GenericPeer
Request(method, path string, param *HTTPRequest) error
}
type HTTPSession interface {
Request() *http.Request
}