-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathhandles.go
51 lines (38 loc) · 1.07 KB
/
handles.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
50
51
package main
import (
"context"
"fmt"
"strings"
)
type DecentralizedID string
type Hostname string
type Domain string
type Username string
type Handle struct {
Domain Domain
Username Username
}
func (handle Handle) String() string {
return strings.ToLower(fmt.Sprintf("%s.%s", handle.Username, handle.Domain))
}
type ProvidesDecentralizedIDs interface {
GetDecentralizedIDForHandle(ctx context.Context, handle Handle) (DecentralizedID, error)
CanProvideForDomain(ctx context.Context, domain Domain) (bool, error)
IsHealthy(ctx context.Context) (bool, string)
}
type DecentralizedIDNotFoundError struct {
handle Handle
}
func (e DecentralizedIDNotFoundError) Error() string {
return fmt.Sprintf("No DID found for %s", e.handle.String())
}
type CannotGetHandelsFromDomainError struct {
domain Domain
}
func (e CannotGetHandelsFromDomainError) Error() string {
return fmt.Sprintf("Domain %s is not supported by this server", e.domain)
}
func (e *CannotGetHandelsFromDomainError) Is(target error) bool {
_, ok := target.(*CannotGetHandelsFromDomainError)
return ok
}