aboutsummaryrefslogtreecommitdiff
path: root/resource.go
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2015-12-10 17:01:14 +0100
committerDimitri Sokolyuk <demon@dim13.org>2015-12-10 17:01:14 +0100
commit54975553c4b67d2b2d9d6edcbf18dbcbdc508fec (patch)
tree368e07db912904c7982358ad60e76a35404121b5 /resource.go
parentf8176a30d5193f77fd7a76492f8245620035ffb7 (diff)
Reimplement registration
Diffstat (limited to 'resource.go')
-rw-r--r--resource.go49
1 files changed, 26 insertions, 23 deletions
diff --git a/resource.go b/resource.go
index b38cbca..ab54a94 100644
--- a/resource.go
+++ b/resource.go
@@ -1,28 +1,31 @@
package acme
-type ResourceValue interface {
- Value() string
-}
+type Resource int
-type NewReg struct {
- Contact []string `json:"contact"`
-}
+const (
+ ResNewReg Resource = iota
+ ResRecoverReg
+ ResNewAuthz
+ ResNewCert
+ ResRevoceCert
+ ResRegister
+ ResAuthz
+ ResChallenge
+ ResCert
+)
-type RecoverReg struct{}
-type NewAuthz struct{}
-type NewCert struct{}
-type RevokeCert struct{}
-type Register struct{}
-type Authz struct{}
-type Challenge struct{}
-type Cert struct{}
+var resources = map[Resource]string{
+ ResNewReg: "new-reg",
+ ResRecoverReg: "recover-reg",
+ ResNewAuthz: "new-authz",
+ ResNewCert: "new-cert",
+ ResRevoceCert: "revoke-cert",
+ ResRegister: "reg",
+ ResAuthz: "authz",
+ ResChallenge: "challenge",
+ ResCert: "cert",
+}
-func (NewReg) Value() string { return "new-reg" }
-func (RecoverReg) Value() string { return "recover-reg" }
-func (NewAuthz) Value() string { return "new-authz" }
-func (NewCert) Value() string { return "new-cert" }
-func (RevokeCert) Value() string { return "revoke-cert" }
-func (Register) Value() string { return "reg" }
-func (Authz) Value() string { return "authz" }
-func (Challenge) Value() string { return "challenge" }
-func (Cert) Value() string { return "cert" }
+func (r Resource) MarshalText() ([]byte, error) {
+ return []byte(resources[r]), nil
+}