Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ language: go
sudo: required

go:
- 1.8
- 1.9

env:
- GO15VENDOREXPERIMENT="1"
Expand Down
18 changes: 16 additions & 2 deletions dotweb.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ const (
// DefaultHTTPPort default http port; fixed for #70 UPDATE default http port 80 to 8080
DefaultHTTPPort = 8080

DefaultLogPath = ""

// RunMode_Development app runmode in development mode
RunMode_Development = "development"
// RunMode_Production app runmode in production mode
Expand Down Expand Up @@ -88,14 +90,18 @@ func New() *DotWeb {
return app
}

// Classic create and return DotApp instance
// Classic create and return DotApp instance\
// if set logPath = "", it will use bin-root/logs for log-root
// 1.SetEnabledLog(true)
// 2.use RequestLog Middleware
// 3.print logo
func Classic() *DotWeb {
func Classic(logPath string) *DotWeb {
app := New()
app.StartMode = StartMode_Classic

if logPath != ""{
app.SetLogPath(logPath)
}
app.SetEnabledLog(true)
app.UseRequestLog()
//print logo
Expand All @@ -104,6 +110,14 @@ func Classic() *DotWeb {
return app
}

// ClassicWithConf create and return DotApp instance
// must set config info
func ClassicWithConf(config *config.Config) *DotWeb{
app := Classic(config.App.LogPath)
app.SetConfig(config)
return app
}

// RegisterMiddlewareFunc register middleware with gived name & middleware
func (app *DotWeb) RegisterMiddlewareFunc(name string, middleFunc MiddlewareFunc) {
app.middlewareMutex.Lock()
Expand Down
2 changes: 1 addition & 1 deletion example/start/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
)

func main(){
app := dotweb.Classic()
app := dotweb.Classic(dotweb.DefaultLogPath)
//app := dotweb.New()
//开启development模式
app.SetDevelopmentMode()
Expand Down
2 changes: 1 addition & 1 deletion logger/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func SetEnabledConsole(enabled bool) {

func InitLog() {
if DefaultLogPath == "" {
DefaultLogPath = file.GetCurrentDirectory()
DefaultLogPath = file.GetCurrentDirectory() +"/logs"
}
if appLog == nil {
appLog = NewXLog()
Expand Down
12 changes: 1 addition & 11 deletions uploadfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,24 +26,14 @@ func NewUploadFile(file multipart.File, header *multipart.FileHeader) *UploadFil
}
}

// 获取文件大小的接口
type sizer interface {
Size() int64
}

//get upload file client-local name
func (f *UploadFile) FileName() string {
return f.fileName
}

//get upload file size
func (f *UploadFile) Size() int64 {
if f.fileSize <= 0 {
if sizer, ok := f.File.(sizer); ok {
f.fileSize = sizer.Size()
}
}
return f.fileSize
return f.Header.Size
}

// SaveFile save file in server-local with filename
Expand Down
8 changes: 8 additions & 0 deletions version.MD
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
## dotweb版本记录:

#### Version 1.4.9.3
* 重要:go版本适配升级为1.9+
* 调整UploadFile.Size实现方法,直接返回Header.Size数据
* 调整dotweb.Classic签名为Classic(logPath string),若传入logPath为空,则默认以"bin-root/logs"为日志目录
* 新增dotweb.ClassicWithConf(config *config.Config),支持初始化传入config设置
* 调整默认Log目录由"bin-root"为"bin-root/logs"
* 2018-04-24 08:30

#### Version 1.4.9.2
* 修复BUG for #112
* 调整CharsetUTF8值为"charset=utf-8"
Expand Down