Add BuildInfo service and template data extension
This commit is contained in:
@ -1,5 +1,12 @@
|
||||
package template
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"gitlab.com/wpetit/goweb/service"
|
||||
"gitlab.com/wpetit/goweb/service/build"
|
||||
)
|
||||
|
||||
// Data is some data to inject into the template
|
||||
type Data map[string]interface{}
|
||||
|
||||
@ -17,3 +24,14 @@ func Extend(data Data, extensions ...DataExtFunc) (Data, error) {
|
||||
}
|
||||
return data, nil
|
||||
}
|
||||
|
||||
func WithBuildInfo(w http.ResponseWriter, r *http.Request, ctn *service.Container) DataExtFunc {
|
||||
return func(data Data) (Data, error) {
|
||||
info, err := build.From(ctn)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
data["BuildInfo"] = info
|
||||
return data, nil
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user