♻️ Simplify error usage in user package
This commit is contained in:
parent
2e30613089
commit
f62ce1db0a
|
@ -2,7 +2,6 @@ package user
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
|
||||||
|
|
||||||
"source.toby3d.me/website/indieauth/internal/domain"
|
"source.toby3d.me/website/indieauth/internal/domain"
|
||||||
)
|
)
|
||||||
|
@ -11,4 +10,4 @@ type Repository interface {
|
||||||
Get(ctx context.Context, me *domain.Me) (*domain.User, error)
|
Get(ctx context.Context, me *domain.Me) (*domain.User, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
var ErrNotExist = errors.New("user not exists")
|
var ErrNotExist error = domain.NewError(domain.ErrorCodeServerError, "user not exist", "")
|
||||||
|
|
|
@ -15,22 +15,20 @@ type httpUserRepository struct {
|
||||||
client *http.Client
|
client *http.Client
|
||||||
}
|
}
|
||||||
|
|
||||||
const DefaultMaxRedirectsCount int = 10
|
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
DefaultMaxRedirectsCount int = 10
|
||||||
|
|
||||||
|
hCard string = "h-card"
|
||||||
|
propertyEmail string = "email"
|
||||||
|
propertyName string = "name"
|
||||||
|
propertyPhoto string = "photo"
|
||||||
|
propertyURL string = "url"
|
||||||
relAuthorizationEndpoint string = "authorization_endpoint"
|
relAuthorizationEndpoint string = "authorization_endpoint"
|
||||||
relIndieAuthMetadata string = "indieauth-metadata"
|
relIndieAuthMetadata string = "indieauth-metadata"
|
||||||
relMicropub string = "micropub"
|
relMicropub string = "micropub"
|
||||||
relMicrosub string = "microsub"
|
relMicrosub string = "microsub"
|
||||||
relTicketEndpoint string = "ticket_endpoint"
|
relTicketEndpoint string = "ticket_endpoint"
|
||||||
relTokenEndpoint string = "token_endpoint"
|
relTokenEndpoint string = "token_endpoint"
|
||||||
|
|
||||||
hCard string = "h-card"
|
|
||||||
|
|
||||||
propertyEmail string = "email"
|
|
||||||
propertyName string = "name"
|
|
||||||
propertyPhoto string = "photo"
|
|
||||||
propertyURL string = "url"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func NewHTTPUserRepository(client *http.Client) user.Repository {
|
func NewHTTPUserRepository(client *http.Client) user.Repository {
|
||||||
|
|
|
@ -16,7 +16,7 @@ import (
|
||||||
func TestFetch(t *testing.T) {
|
func TestFetch(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
me := domain.TestMe(t)
|
me := domain.TestMe(t, "https://user.example.net")
|
||||||
user := domain.TestUser(t)
|
user := domain.TestUser(t)
|
||||||
|
|
||||||
store := new(sync.Map)
|
store := new(sync.Map)
|
||||||
|
|
Loading…
Reference in New Issue