domain_spi.go 565 B

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