-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhttpserver.go
More file actions
39 lines (31 loc) · 932 Bytes
/
httpserver.go
File metadata and controls
39 lines (31 loc) · 932 Bytes
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
package httpserver
import (
"net/http"
)
var (
POST string = "POST"
PUT string = "PUT"
GET string = "GET"
DELETE string = "DELETE"
OPTIONS string = "OPTIONS"
HEAD string = "HEAD"
TRACE string = "TRACE"
CONNECT string = "CONNECT"
)
type HandleFunc func(w http.ResponseWriter, r *http.Request, param CUrlParam, server CHttpServer, userdata interface{}) bool
type CHttpServer interface {
Subscribe(topic string, method string, handler CRouterHandler)
ServeHTTP(w http.ResponseWriter, r *http.Request)
}
type CUrlParam interface {
ByName(name string) *string
}
type CRouterHandler interface {
handler(w http.ResponseWriter, r *http.Request, param CUrlParam, server CHttpServer) bool
}
func NewHttpServer() CHttpServer {
return &httpServerImpl{}
}
func NewRouterHandler(userdata interface{}, handle HandleFunc) CRouterHandler {
return &routerHandler{m_userData: userdata, m_handlerFunc: handle}
}