Skip to content

Commit

Permalink
Merge pull request #52 from fraunhoferfokus/development
Browse files Browse the repository at this point in the history
* in restSvc.go you can add additional Handler outside OpenAPI
  • Loading branch information
JGottschick authored Oct 17, 2024
2 parents b4b1fb6 + b9e7d50 commit e733a3e
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 3 deletions.
2 changes: 1 addition & 1 deletion core/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.3.9
0.3.10
8 changes: 8 additions & 0 deletions generator/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,4 +205,12 @@ func generateHandlerFuncs(spec *openapi3.T, genConf GeneratorConfig) {
filePath := filepath.Join(config.Path, RestPkg, fileName)
templateFile := "templates/rest/handler.go.tmpl"
createFileFromTemplate(filePath, templateFile, conf)

fileName = "restSvc.go"
filePath = filepath.Join(config.Path, RestPkg, fileName)
templateFile = "templates/rest/restSvc.go.tmpl"
if _, err := os.Stat(filePath); errors.Is(err, os.ErrNotExist) {
createFileFromTemplate(filePath, templateFile, conf)
}

}
2 changes: 1 addition & 1 deletion templates/core/config.go.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func init() {
}

// extend custom flags
init_ext()
initExt()

flag.Parse()

Expand Down
2 changes: 1 addition & 1 deletion templates/core/configSvc.go.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ type ConfigExt struct {
}

// define custom cli flags, ...
func init_ext() {
func initExt() {
}
3 changes: 3 additions & 0 deletions templates/rest/handler.go.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,7 @@ func NewHandler(e *echo.Echo){
{{- end }}

{{- end }}

// Call handler extensions
newHandlerExt(e)
}
12 changes: 12 additions & 0 deletions templates/rest/restSvc.go.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Edit this file, as it is a specific for your service
package rest

func newHandlerExt(e *echo.Echo) {
// g := e.Group("")

// Add your own handler
//
// But aware, that these are hidden from your OpenAPI
//
// g.GET("/myfunc", GetMyFunc)
}

0 comments on commit e733a3e

Please sign in to comment.