forked from alash3al/sqler
-
Notifications
You must be signed in to change notification settings - Fork 1
/
vars.go
52 lines (43 loc) · 1.51 KB
/
vars.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
// Copyright 2018 The SQLer Authors. All rights reserved.
// Use of this source code is governed by a Apache 2.0
// license that can be found in the LICENSE file.
package main
import (
"errors"
"flag"
"runtime"
)
var (
flagDBDriver = flag.String("driver", "mysql", "the sql driver to be used")
flagDBDSN = flag.String("dsn", "root:root@tcp(127.0.0.1)/test?multiStatements=true", "the data source name for the selected engine")
flagAPIFile = flag.String("config", "./config.example.hcl", "the config file(s) that contains your endpoints configs, it accepts comma seprated list of glob style pattern")
flagRESTListenAddr = flag.String("rest", ":8025", "the http restful api listen address")
flagRESPListenAddr = flag.String("resp", ":3678", "the resp (redis protocol) server listen address")
flagWorkers = flag.Int("workers", runtime.NumCPU(), "the maximum workers count")
)
var (
errNoMacroFound = errors.New("Resource not found")
errValidationError = errors.New("Validation error")
errAuthorizationError = errors.New("Authorization Error")
)
var (
errStatusCodeMap = map[error]int{
errNoMacroFound: 404,
errValidationError: 422,
errAuthorizationError: 401,
}
)
var (
macrosManager *Manager
)
const (
sqlerVersion = "v2.1"
sqlerBrand = `
____ ___ _
/ ___| / _ \| | ___ _ __
\___ \| | | | | / _ \ '__|
___) | |_| | |__| __/ |
|____/ \__\_\_____\___|_|
turn your SQL queries into safe valid RESTful apis.
`
)