📝 README and inline docs
This commit is contained in:
parent
d533a879ef
commit
c61300c6b8
14 changed files with 139 additions and 24 deletions
|
|
@ -18,6 +18,7 @@ import (
|
|||
"github.com/labstack/echo/middleware"
|
||||
)
|
||||
|
||||
// Serve takes a bind-address and starts the HTTP server.
|
||||
func Serve(bindAddr string) error {
|
||||
e := echo.New()
|
||||
e.Pre(middleware.RemoveTrailingSlash())
|
||||
|
|
@ -75,6 +76,7 @@ func handleNewVoting(ctx echo.Context) error {
|
|||
case "d":
|
||||
d = time.Now().UTC().Add(time.Duration(deadlineInt) * time.Hour * 24).Round(time.Second)
|
||||
default:
|
||||
// TODO: this needs better handling!
|
||||
panic("this code should never be reached")
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,6 @@
|
|||
// labstack/echo requires a custom TemplateRenderer.
|
||||
// This module implements it.
|
||||
|
||||
package http
|
||||
|
||||
import (
|
||||
|
|
@ -7,14 +10,17 @@ import (
|
|||
"github.com/labstack/echo"
|
||||
)
|
||||
|
||||
// Template is a data-container for a template.
|
||||
type Template struct {
|
||||
Templates *template.Template
|
||||
}
|
||||
|
||||
// Render injects the echo.Context into the template renderer.
|
||||
func (t *Template) Render(w io.Writer, name string, data interface{}, c echo.Context) error {
|
||||
return t.Templates.ExecuteTemplate(w, name, data)
|
||||
}
|
||||
|
||||
// NewTemplateRenderer returns an initialized Template and injects the patched Renderer.
|
||||
func NewTemplateRenderer(e *echo.Echo, paths ...string) {
|
||||
tmpl := &template.Template{}
|
||||
for i := range paths {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue