35 lines
736 B
Go
35 lines
736 B
Go
|
package lib
|
||
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
"log"
|
||
|
"path/filepath"
|
||
|
|
||
|
"git.ymnuktech.ru/ymnuk/yt-gen-app/lib/templ"
|
||
|
"git.ymnuktech.ru/ymnuk/yt-gen-app/structs"
|
||
|
)
|
||
|
|
||
|
func generateBackendRest() {
|
||
|
|
||
|
type RestStruct struct {
|
||
|
Path string
|
||
|
Project *structs.Project
|
||
|
Rest *structs.Rest
|
||
|
}
|
||
|
|
||
|
if len(Project.Backend.Rest) > 0 {
|
||
|
for i := range Project.Backend.Rest {
|
||
|
restStruct := &RestStruct{
|
||
|
Project: Project,
|
||
|
Path: i,
|
||
|
Rest: Project.Backend.Rest[i],
|
||
|
}
|
||
|
destPath := filepath.Join(AppConfig.OutdirBackend, "route", "api", i)
|
||
|
fmt.Println(destPath)
|
||
|
if err := templ.PrepareTmplFile("tmpl/backend/route/api/templ/index.tmpl", restStruct, filepath.Join(destPath, "index.go")); err != nil {
|
||
|
log.Fatal(err)
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|