domain_spi.go 693 B

1234567891011121314151617181920212223242526
  1. package domain
  2. var shortURLRepository ShortURLRepository
  3. var targetURLRepository TargetURLRepository
  4. type ShortURLRepository interface {
  5. GetTarget(su ShortURL) (TargetURL, error)
  6. }
  7. /*
  8. TargetURLRepository is the interface infrastructure needs to implement to
  9. provide the domain with access to Target URLs.
  10. */
  11. type TargetURLRepository interface {
  12. /*
  13. GetShort returns the ShortURL for a given TargetURL.
  14. In the results, isNew will be true if the ShortURL was created for this occasion.
  15. */
  16. GetShort(tu TargetURL) (su ShortURL, isNew bool, err error)
  17. }
  18. func RegisterRepositories(sur ShortURLRepository, tur TargetURLRepository) {
  19. shortURLRepository = sur
  20. targetURLRepository = tur
  21. }