/
type.go
91 lines (80 loc) · 2.08 KB
/
type.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
package wobj
import (
"encoding/json"
"net/http"
"time"
"github.com/gorilla/websocket"
)
const (
maxArgLeg = 100000 // Максимальная длина аргумента передаваемого в js
nodeScript = "/usr/bin/nodejs"
)
// Param это переменные для инициализации класса
type Param struct {
Port int
Route func(*Obj)
WsRoute func(*http.Request, *WsConn)
WsPath string
MaxArgLeg int
YateScript string
NodeScript string
Cookie Cookie
CspMap map[string]string
Csp string
ParseRequest func(http.ResponseWriter, *http.Request)
Middlewares []func(next http.Handler) http.Handler
PerfomanceLog string
AlwaysJSON bool
}
// Cookie - Объект с описание кукисов
type Cookie struct {
Name string
Domain string
Path string
Time int
Secure bool
}
// Obj основной объект запроса
type Obj struct {
W http.ResponseWriter
R *http.Request
TimeStart time.Time
Ans Answer
AppendFunc func(*Obj, map[string]interface{}) map[string]interface{}
Cache map[string]interface{}
Debug bool
ServerTiming bool
}
// Answer объект содержащий ответ
type Answer struct {
Path []string
Redirect string
Cookie string
Data interface{}
Exited bool
Code int
Meta AnswerMeta
IsJSON bool
CspMap map[string]string
}
// AnswerMeta объект содержит заголовок и описание страницы
type AnswerMeta struct {
Title string `json:"title"`
Description string `json:"description"`
}
type perfomanceData struct {
Path string `json:"path"`
Duration int64 `json:"duration"`
}
// WsData - структура данны хдля веб-сокета
type WsData struct {
Action string `json:"action"`
Data json.RawMessage `json:"data"`
}
// WsConn - объект коннекта вебсокета
type WsConn struct {
Reader chan []byte
Writer chan []byte
Close chan bool
Conn *websocket.Conn
}