-
Notifications
You must be signed in to change notification settings - Fork 2
/
sandbox_controller.go
49 lines (38 loc) · 1.08 KB
/
sandbox_controller.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package pezauth
import (
"fmt"
"net/http"
"github.com/martini-contrib/render"
)
//SUBJECT - Email subject for sandbox request
const SUBJECT = "Pez Request: Sandbox"
//BODY - Email body for sandbox request
const BODY = `To whom it may concern:
I am requesting a PEZ Sandbox environment.
My info:
%s
%s
Thank you.
`
//NewSandBoxController - Create a Sandbox controller instance
func NewSandBoxController() Controller {
return &sandBoxController{}
}
//SandBoxPostHandler Post Email send
type SandBoxPostHandler func(render.Render, *http.Request, Sender)
//Post - Post a sandbox request
func (e *sandBoxController) Post() interface{} {
var handler SandBoxPostHandler = func(r render.Render, request *http.Request, emailServer Sender) {
to := emailServer.GetSupportEmail()
from, name := request.FormValue("from"), request.FormValue("name")
emailData := &SMTPData{
From: from,
To: to,
Subject: SUBJECT,
Body: fmt.Sprintf(BODY, name, from),
}
err := emailServer.SendEmail(emailData)
genericResponseFormatter(r, "", map[string]interface{}{}, err)
}
return handler
}