Commit Diff


commit - be20893f819a5320fcf7aae0fd66f48c2e1651ed
commit + f4dc4985003737550d70f56d782cecc2c0e3b192
blob - 5af8e3e5a81c2cd5ecd88534cf731e7c5465055b
blob + bb132cc62006889ebd5ab1628839011082345374
--- docs/httpapiref.md
+++ docs/httpapiref.md
@@ -78,7 +78,7 @@ Any mail addressed to the recipient of the alias will 
 {
   "Recipient": "wondering_underbelly71",
   "Destination": "test@example.com",
-  "Expiry": 1845067777,
+  "Expiry": "2006-01-02T15:04:05Z07:00",
   "Note": "newsletters for example.org"
 }
 ```
@@ -93,8 +93,8 @@ implementation.</dd>
 <dt><code>Destination</code> string</dt>
 <dd>Destination contains an email address, with domain suffix,
 to which mail will be forwarded.</dd>
-<dt><code>Expiry</code> integer</dt>
-<dd>Expiry specifies a time in seconds since the UNIX epoch
+<dt><code>Expiry</code> string</dt>
+<dd>Expiry specifies a time in RFC3339 format
 after which the alias is considered inactive;
 that is, mail addressed to Recipient should be bounced.</dd>
 <dt><code>Note</code> string</dt>
@@ -112,7 +112,7 @@ POST /v1/aliases
 {
   "Recipient": "wondering_underbelly71",
   "Destination": "test@example.com",
-  "Expiry": 1845067777,
+  "Expiry": "2006-01-02T15:04:05Z07:00",
   "Note": "newsletters for example.org"
 }
 ```
@@ -124,12 +124,12 @@ Otherwise, an error is returned.
 ### Parameters
 
 <dl>
-<dt><code>Expiry</code> optional integer</dt>
-<dd>Expiry specifies a time in seconds since the UNIX epoch
+<dt><code>expiry</code> optional string</dt>
+<dd>Expiry specifies a time in RFC3339 format
 after which the alias is considered inactive;
 that is, mail addressed to Recipient should be bounced.
 By default, aliases never expire.</dd>
-<dt><code>Note</code> optional string</dt>
+<dt><code>note</code> optional string</dt>
 <dd>Note contains user-defined text that can be used to, for example, identify the alias.
 By default, aliases have no note.</dd>
 </dl>
@@ -144,7 +144,7 @@ GET /v1/aliases/:recipient
 {
   "Recipient": "wondering_underbelly71",
   "Destination": "test@example.com",
-  "Expiry": 1845067777,
+  "Expiry": "2006-01-02T15:04:05Z07:00",
   "Note": "newsletters for example.org"
 }
 ```
@@ -166,13 +166,13 @@ GET /v1/aliases
   {
     "Recipient": "wondering_underbelly71",
     "Destination": "test@example.com",
-    "Expiry": 1845067777,
+    "Expiry": "2006-01-02T15:04:05Z07:00",
     "Note": "newsletters for example.org"
   },
   {
     "Recipient": "humble_anteater48",
     "Destination": "test@example.com",
-    "Expiry": 1845067777,
+    "Expiry": "2006-01-02T15:04:05Z07:00",
     "Note": "supermarket rewards card"
   }
 ]
@@ -198,8 +198,8 @@ To unset parameters, set their values to the empty str
 This can be used to, for example, remove an alias' expiry time.
 
 <dl>
-<dt><code>Expiry</code> optional integer</dt>
-<dd>Expiry specifies a time in seconds since the UNIX epoch
+<dt><code>expiry</code> optional string</dt>
+<dd>Expiry specifies a time in RFC3339 format
 after which the alias is considered inactive;
 that is, mail addressed to Recipient should be bounced.
 By default, aliases never expire.</dd>
blob - 0b890f911e3eba88a8ed52c81ccfa8deb4b7489d
blob + 6900c57608e3939ff6ad832989e9042986ddf98b
--- http.go
+++ http.go
@@ -6,7 +6,6 @@ import (
 	"fmt"
 	"net/http"
 	"path"
-	"strconv"
 	"strings"
 	"time"
 )
@@ -114,16 +113,15 @@ func (h *aliasHandler) ServeHTTP(w http.ResponseWriter
 		for param := range req.PostForm {
 			switch param {
 			case "expiry":
-				i, err := strconv.Atoi(req.PostForm.Get(param))
+				alias.Expiry, err = time.Parse(time.RFC3339, req.PostForm.Get(param))
 				if err != nil {
 					jerror(w, fmt.Sprintf("parse expiry: %v", err), http.StatusBadRequest)
 					return
 				}
-				alias.Expiry = time.Unix(int64(i), 0)
 			case "note":
 				alias.Note = req.PostForm.Get(param)
 			default:
-				jerror(w, fmt.Sprintf("invalid alias parameter %s", param), http.StatusBadRequest)
+				jerror(w, fmt.Sprintf("bad alias parameter %s", param), http.StatusBadRequest)
 				return
 			}
 		}
@@ -134,7 +132,8 @@ func (h *aliasHandler) ServeHTTP(w http.ResponseWriter
 		json.NewEncoder(w).Encode(alias)
 
 	default:
-		jerror(w, "not implemented yet", http.StatusMethodNotAllowed)
+		code := http.StatusMethodNotAllowed
+		jerror(w, http.StatusText(code), code)
 	}
 }