M core/local.go => core/local.go +15 -0
@@ 68,3 68,18 @@ func GetSessionGlobalLocalizer(c echo.Context) *localizer.Localizer {
lang := GetLang(c)
return localizer.GetGlobal(lang)
}
+
+// PageData holds translations for html template values
+type PageData struct {
+ Title string
+ Data map[string]string
+}
+
+// NewPageData returns a new PageData instance
+func NewPageData(title string) *PageData {
+ return &PageData{
+ Title: title,
+ Data: make(map[string]string),
+ }
+
+}
M server/server.go => server/server.go +11 -0
@@ 61,6 61,12 @@ func (a *appInfo) Version() string {
return a.version
}
+// Extension is an interface to add on to the Server instance via a 3rd
+// party module
+type Extension interface {
+ Extend(gserver *Server) (*Server, error)
+}
+
// GraphQL is a holder for a graphql schema and options
type GraphQL struct {
Schema graphql.ExecutableSchema
@@ 486,6 492,11 @@ func (s *Server) addDefaultTemplateData() {
s.AddStaticVar("BaseURI", s.Config.BaseURI())
}
+// Extend will apply the given Extension interface
+func (s *Server) Extend(ext Extension) (*Server, error) {
+ return ext.Extend(s)
+}
+
// WithSchema Adds a GraphQL schema for this server. The second parameter
// shall be the list of scopes, as strings, which are supported by this
// schema. This function configures routes for the router; all middlewares
M validate/template.go => validate/template.go +5 -0
@@ 32,6 32,11 @@ type (
protect bool
allowed []string
}
+
+ // TemplateRenderFunc defines a function to render a template. The `code` variable is the
+ // response status code. The `name` is the template name. The `data` variable should be what
+ // is passed to the template engine for use inside the templates.
+ TemplateRenderFunc func(c echo.Context, code int, name string, data interface{}) error
)
// NewTemplate returns a *Template instance