A tool for crawling and finding links to URLs which no longer exist
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
deadlinks/resource.go

46 lines
1.1 KiB

package deadlinks
import (
"fmt"
"time"
)
// ResourceStatus describes what state a particular Resource is in.
type ResourceStatus int
// Enumeration of ResourceStatus values.
const (
ResourceStatusUnknown ResourceStatus = iota
ResourceStatusOK
ResourceStatusError
)
func (ds ResourceStatus) String() string {
switch ds {
case ResourceStatusUnknown:
return "UNKNOWN"
case ResourceStatusOK:
return "OK"
case ResourceStatusError:
return "ERROR"
default:
panic(fmt.Sprintf("unknown ResourceStatus: %#v", ds))
}
}
// Resource describes the current state of a resource, with the resource being
// uniquely identified by a URL.
type Resource struct {
URL URL
Status ResourceStatus `yaml:"-"`
Pinned bool `yaml:"-"`
LastChecked time.Time `yaml:"last_checked"`
// only set if Status == ResourceStatusError
ErrorString string `yaml:"error"`
// Indicate the URLs of resources which link to/are linked from this
// resource.
IncomingLinkURLs []URL `yaml:"incoming_links"`
OutgoingLinkURLs []URL `yaml:"outgoing_links"`
}