Added handler examples for caching and tasks.
This commit is contained in:
parent
5707343d57
commit
2004d6b139
8 changed files with 264 additions and 16 deletions
|
|
@ -2,14 +2,11 @@ package handlers
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/go-playground/validator/v10"
|
||||
"github.com/labstack/echo/v4"
|
||||
"github.com/mikestefanello/pagoda/pkg/form"
|
||||
"github.com/mikestefanello/pagoda/pkg/page"
|
||||
"github.com/mikestefanello/pagoda/pkg/services"
|
||||
"github.com/mikestefanello/pagoda/pkg/tasks"
|
||||
"github.com/mikestefanello/pagoda/templates"
|
||||
)
|
||||
|
||||
|
|
@ -20,8 +17,7 @@ const (
|
|||
|
||||
type (
|
||||
Contact struct {
|
||||
mail *services.MailClient
|
||||
tasks *services.TaskClient
|
||||
mail *services.MailClient
|
||||
*services.TemplateRenderer
|
||||
}
|
||||
|
||||
|
|
@ -40,7 +36,6 @@ func init() {
|
|||
func (h *Contact) Init(c *services.Container) error {
|
||||
h.TemplateRenderer = c.TemplateRenderer
|
||||
h.mail = c.Mail
|
||||
h.tasks = c.Tasks
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
@ -72,16 +67,6 @@ func (h *Contact) Submit(ctx echo.Context) error {
|
|||
return err
|
||||
}
|
||||
|
||||
// TODO create a new page for this
|
||||
err = h.tasks.New(tasks.ExampleTask{
|
||||
Message: input.Message,
|
||||
}).
|
||||
Wait(10 * time.Second).
|
||||
Save()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = h.mail.
|
||||
Compose().
|
||||
To(input.Email).
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue