forked from YaoApp/yao
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
57 changed files
with
779 additions
and
637 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,3 +22,4 @@ ui | |
tests/data/*/* | ||
debug.log | ||
yao-test | ||
dev.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,40 @@ | ||
package api | ||
|
||
import ( | ||
"fmt" | ||
"path/filepath" | ||
|
||
"github.com/yaoapp/gou" | ||
"github.com/yaoapp/kun/log" | ||
"github.com/yaoapp/xiang/config" | ||
"github.com/yaoapp/xiang/share" | ||
) | ||
|
||
// Load 加载API | ||
func Load(cfg config.Config) { | ||
LoadFrom(cfg.RootAPI, "") | ||
func Load(cfg config.Config) error { | ||
if share.BUILDIN { | ||
return LoadBuildIn("apis", "") | ||
} | ||
return LoadFrom(filepath.Join(cfg.Root, "apis"), "") | ||
} | ||
|
||
// LoadFrom 从特定目录加载 | ||
func LoadFrom(dir string, prefix string) { | ||
|
||
func LoadFrom(dir string, prefix string) error { | ||
if share.DirNotExists(dir) { | ||
return | ||
return fmt.Errorf("%s does not exists", dir) | ||
} | ||
|
||
share.Walk(dir, ".http.json", func(root, filename string) { | ||
err := share.Walk(dir, ".http.json", func(root, filename string) { | ||
name := prefix + share.SpecName(root, filename) | ||
content := share.ReadFile(filename) | ||
gou.LoadAPI(string(content), name) | ||
_, err := gou.LoadAPIReturn(string(content), name) | ||
if err != nil { | ||
log.With(log.F{"root": root, "file": filename}).Error(err.Error()) | ||
} | ||
}) | ||
return err | ||
} | ||
|
||
// LoadBuildIn 从制品中读取 | ||
func LoadBuildIn(dir string, prefix string) error { | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.