This repository has been archived by the owner on Feb 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 49
/
default.go
73 lines (65 loc) · 1.82 KB
/
default.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
// Copyright 2019 The bigfile Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
package config
import (
"os"
"time"
"github.com/op/go-logging"
)
// DefaultConfig define a default configurator
var DefaultConfig *Configurator
func init() {
var (
dbPassword = "root"
dbUser = "root"
)
if v, ok := os.LookupEnv("BIGFILE_DEFAULT_DB_PWD"); ok {
dbPassword = v
}
if v, ok := os.LookupEnv("BIGFILE_DEFAULT_DB_USER"); ok {
dbUser = v
}
// DefaultConfig define a default configurator
DefaultConfig = &Configurator{
Database{
Driver: "mysql",
Host: "127.0.0.1",
Port: 3306,
User: dbUser,
Password: dbPassword,
DBName: "bigfile",
},
Log{
Console: ConsoleLog{
Level: LevelToName[logging.DEBUG],
Enable: true,
Format: `%{color:bold}[%{time:2006/01/02 15:04:05.000}] %{pid} %{level:.5s} %{color:reset} %{message}`,
},
File: FileLog{
Enable: true,
Level: LevelToName[logging.WARNING],
Format: "[%{time:2006/01/02 15:04:05.000}] %{pid} %{longfile} %{longfunc} %{callpath} ▶ %{level:.4s} %{message}",
Path: "storage/logs/bigfile.log",
MaxBytesPerFile: 52428800,
},
},
HTTP{
APIPrefix: "/api/bigfile",
AccessLogFile: "storage/logs/bigfile.http.access.log",
LimitRateByIPEnable: false,
LimitRateByIPInterval: 1000,
LimitRateByIPMaxNum: 100,
CORSEnable: false,
CORSAllowAllOrigins: false,
CORSAllowCredentials: false,
CORSAllowHeaders: []string{"Origin"},
CORSAllowOrigins: []string{"*"},
CORSAllowMethods: []string{"PUT", "DELETE", "PATCH"},
CORSMaxAge: 3600 * int64(time.Second),
},
Chunk{
RootPath: "storage/chunks",
},
}
}