Example #1
0
// NewHTTP create a HTTP
func NewHTTP(port string, classifier *Classifier) *HTTP {
	t := new(HTTP)
	t.port = port
	rootDir := util.GetDir()
	t.tplDir = rootDir + "/html"
	t.assetsDir = rootDir + "/assets"
	t.classifier = classifier
	return t
}
Example #2
0
func NewFileStorage(path string) (*FileStorage, error) {
	t := new(FileStorage)
	// 修正路径
	if path[0] != '/' {
		rootDir := util.GetDir()
		path = rootDir + "/" + path
	}
	t.path = path

	// 判断存储路径是否存在
	ok := util.IsExist(filepath.Dir(path))
	if ok == false {
		return nil, errors.New("存储路径不存在: " + filepath.Dir(path))
	}
	// 判断路径是否可写
	ok = util.IsWritable(filepath.Dir(path))
	if ok == false {
		return nil, errors.New("存储路径不可写: " + filepath.Dir(path))
	}

	return t, nil
}