1
0
mirror of https://github.com/jhillyerd/inbucket.git synced 2025-12-17 17:47:03 +00:00

policy: Create new policy package for #84

This commit is contained in:
James Hillyerd
2018-03-17 09:18:28 -07:00
parent 9b3d3c2ea8
commit d132efd6fa
10 changed files with 388 additions and 433 deletions

View File

@@ -11,6 +11,7 @@ import (
"strconv"
"github.com/jhillyerd/inbucket/pkg/log"
"github.com/jhillyerd/inbucket/pkg/policy"
"github.com/jhillyerd/inbucket/pkg/rest/model"
"github.com/jhillyerd/inbucket/pkg/server/web"
"github.com/jhillyerd/inbucket/pkg/storage"
@@ -20,7 +21,7 @@ import (
// MailboxListV1 renders a list of messages in a mailbox
func MailboxListV1(w http.ResponseWriter, req *http.Request, ctx *web.Context) (err error) {
// Don't have to validate these aren't empty, Gorilla returns 404
name, err := stringutil.ParseMailboxName(ctx.Vars["name"])
name, err := policy.ParseMailboxName(ctx.Vars["name"])
if err != nil {
return err
}
@@ -50,7 +51,7 @@ func MailboxListV1(w http.ResponseWriter, req *http.Request, ctx *web.Context) (
func MailboxShowV1(w http.ResponseWriter, req *http.Request, ctx *web.Context) (err error) {
// Don't have to validate these aren't empty, Gorilla returns 404
id := ctx.Vars["id"]
name, err := stringutil.ParseMailboxName(ctx.Vars["name"])
name, err := policy.ParseMailboxName(ctx.Vars["name"])
if err != nil {
return err
}
@@ -100,7 +101,7 @@ func MailboxShowV1(w http.ResponseWriter, req *http.Request, ctx *web.Context) (
// MailboxPurgeV1 deletes all messages from a mailbox
func MailboxPurgeV1(w http.ResponseWriter, req *http.Request, ctx *web.Context) (err error) {
// Don't have to validate these aren't empty, Gorilla returns 404
name, err := stringutil.ParseMailboxName(ctx.Vars["name"])
name, err := policy.ParseMailboxName(ctx.Vars["name"])
if err != nil {
return err
}
@@ -118,7 +119,7 @@ func MailboxPurgeV1(w http.ResponseWriter, req *http.Request, ctx *web.Context)
func MailboxSourceV1(w http.ResponseWriter, req *http.Request, ctx *web.Context) (err error) {
// Don't have to validate these aren't empty, Gorilla returns 404
id := ctx.Vars["id"]
name, err := stringutil.ParseMailboxName(ctx.Vars["name"])
name, err := policy.ParseMailboxName(ctx.Vars["name"])
if err != nil {
return err
}
@@ -142,7 +143,7 @@ func MailboxSourceV1(w http.ResponseWriter, req *http.Request, ctx *web.Context)
func MailboxDeleteV1(w http.ResponseWriter, req *http.Request, ctx *web.Context) (err error) {
// Don't have to validate these aren't empty, Gorilla returns 404
id := ctx.Vars["id"]
name, err := stringutil.ParseMailboxName(ctx.Vars["name"])
name, err := policy.ParseMailboxName(ctx.Vars["name"])
if err != nil {
return err
}