-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
57 lines (43 loc) · 2.74 KB
/
main.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
package main
import (
"github.com/sad0vnikov/radish/config"
"github.com/sad0vnikov/radish/http/api"
"github.com/sad0vnikov/radish/http/server"
"github.com/sad0vnikov/radish/logger"
)
func main() {
logger.Info("init app...")
var configLoader config.Loader
configPath := "config.json"
configLoader = config.JSONFileConfigLoader{Path: configPath}
logger.Infof("read config from %v", configPath)
_, err := configLoader.Load()
if err != nil {
panic(err)
}
server := server.HTTPServer{Port: 8080}
server.AddHandler("GET", api.Version()+"/servers", api.GetServersList)
server.AddHandler("GET", api.Version()+"/servers/{server}/databasesCount", api.GetMaxDbNumber)
server.AddHandler("GET", api.Version()+"/servers/{server}/keys", api.GetKeysByMask)
server.AddHandler("GET", api.Version()+"/servers/{server}/keys/{key}/info", api.GetKeyInfo)
server.AddHandler("GET", api.Version()+"/servers/{server}/keys/{key}/values", api.GetKeyValues)
server.AddHandler("GET", api.Version()+"/servers/{server}/keys-tree", api.GetKeysSubtree)
server.AddHandler("DELETE", api.Version()+"/servers/{server}/keys/{key}", api.DeleteKey)
server.AddHandler("POST", api.Version()+"/servers/{server}/keys/strings/{key}", api.AddStringValue)
server.AddHandler("PUT", api.Version()+"/servers/{server}/keys/strings/{key}", api.UpdateStringValue)
server.AddHandler("POST", api.Version()+"/servers/{server}/keys/lists/{key}/values", api.AddListValue)
server.AddHandler("PUT", api.Version()+"/servers/{server}/keys/lists/{key}/values/{index}", api.UpdateListValue)
server.AddHandler("DELETE", api.Version()+"/servers/{server}/keys/lists/{key}/values/{index}", api.DeleteListValue)
server.AddHandler("POST", api.Version()+"/servers/{server}/keys/hashes/{key}/values", api.AddHashValue)
server.AddHandler("PUT", api.Version()+"/servers/{server}/keys/hashes/{key}/values/{hashKey}", api.UpdateHashValue)
server.AddHandler("DELETE", api.Version()+"/servers/{server}/keys/hashes/{key}/values/{hashKey}", api.DeleteHashValue)
server.AddHandler("POST", api.Version()+"/servers/{server}/keys/sets/{key}/values", api.AddSetValue)
server.AddHandler("PUT", api.Version()+"/servers/{server}/keys/sets/{key}/values/{value}", api.UpdateSetValue)
server.AddHandler("DELETE", api.Version()+"/servers/{server}/keys/sets/{key}/values/{value}", api.DeleteSetValue)
server.AddHandler("POST", api.Version()+"/servers/{server}/keys/zsets/{key}/values", api.AddZSetValue)
server.AddHandler("PUT", api.Version()+"/servers/{server}/keys/zsets/{key}/values/{value}", api.UpdateZSetValue)
server.AddHandler("DELETE", api.Version()+"/servers/{server}/keys/zsets/{key}/values/{value}", api.DeleteZSetValue)
server.AddHandler("GET", api.Version()+"/appVersion", api.GetAppVersion)
server.ServeStatic()
server.Init()
}