-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathtypes.go
More file actions
99 lines (88 loc) · 2.95 KB
/
Copy pathtypes.go
File metadata and controls
99 lines (88 loc) · 2.95 KB
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
92
93
94
95
96
97
98
99
package main
import (
"database/sql"
"net/http"
"sync"
"github.com/elgs/gosqlcrud"
)
const maxBodySize = 10 * 1024 * 1024 // 10MB
type App struct {
Web *Web `json:"web"`
Databases map[string]*Database `json:"databases"`
Scripts map[string]*Script `json:"scripts"`
Tables map[string]*Table `json:"tables"`
Tokens map[string][]*Access `json:"tokens"`
ManagedTokens *ManagedTokens `json:"managed_tokens"`
CacheTokens bool `json:"cache_tokens"`
NullValue any `json:"null_value"`
tokenCache map[string][]*Access
tokenCacheMu sync.RWMutex
}
type Web struct {
HttpAddr string `json:"http_addr"`
HttpsAddr string `json:"https_addr"`
CertFile string `json:"cert_file"`
KeyFile string `json:"key_file"`
Cors bool `json:"cors"`
HttpHeaders map[string]string `json:"http_headers"`
httpServer *http.Server
httpsServer *http.Server
}
type Database struct {
Type string `json:"type"`
Url string `json:"url"`
dbType gosqlcrud.DbType
conn *sql.DB
mu sync.Mutex
}
type Access struct {
TargetDatabase string `json:"target_database" db:"target_database"`
TargetObjectArray []string `json:"target_objects"`
TargetObjects string `db:"target_objects"`
ReadPrivate bool `json:"read_private" db:"read_private"`
WritePrivate bool `json:"write_private" db:"write_private"`
ExecPrivate bool `json:"exec_private" db:"exec_private"`
AllowedOriginArray []string `json:"allowed_origins"`
AllowedOrigins string `db:"allowed_origins"`
}
type ManagedTokens struct {
Database string `json:"database"`
TableName string `json:"table_name"`
Query string `json:"query"`
QueryPath string `json:"query_path"`
Token string `json:"token"`
TargetDatabase string `json:"target_database"`
TargetObjects string `json:"target_objects"`
ReadPrivate string `json:"read_private"`
WritePrivate string `json:"write_private"`
ExecPrivate string `json:"exec_private"`
AllowedOrigins string `json:"allowed_origins"`
}
type Statement struct {
Label string
SQL string
Params []string
Query bool
Export bool
Script *Script
}
type Script struct {
Database string `json:"database"`
SQL string `json:"sql"`
Path string `json:"path"`
PublicExec bool `json:"public_exec"`
Statements []*Statement
built bool
mu sync.Mutex
}
type Table struct {
Database string `json:"database"`
Name string `json:"name"`
PrimaryKey string `json:"primary_key"` // default to "ID"
ExportedColumns []string `json:"exported_columns"` // empty means all
PublicRead bool `json:"public_read"`
PublicWrite bool `json:"public_write"`
PageSize int `json:"page_size"`
OrderBy string `json:"order_by"`
ShowTotal bool `json:"show_total"`
}