package got

import (
	"text/template"

	. "git.eugeniocarvalho.dev/eugeniucarvalho/apicodegen/common"
)

var (
	hookStmtsTmpl *template.Template
	hookStmtsErr  error
)

func init() {
	hookStmtsTmpl, hookStmtsErr = ParseTemplate(`
	import(
		{{range $label, $path := .imports}}
			{{$label}} "{{$path}}"
		{{end}}
	)
	{{if .hasContext}}
	func {{.function}}(options map[string]interface{}) func( context.Context) (interface{},*errs.Error) {
		return func(ctx context.Context) (resp interface{}, err *errs.Error) {
			return
		}
	}
	{{else}}
	func {{.function}}(ctx context.Context) (resp interface{}, err *errs.Error) {
		return
	}
	{{end}}
	`)

	if hookStmtsErr != nil {
		panic(hookStmtsErr)
	}
}
