summaryrefslogtreecommitdiff
path: root/internal/url/addr.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/url/addr.go')
-rw-r--r--internal/url/addr.go32
1 files changed, 32 insertions, 0 deletions
diff --git a/internal/url/addr.go b/internal/url/addr.go
new file mode 100644
index 0000000..555a596
--- /dev/null
+++ b/internal/url/addr.go
@@ -0,0 +1,32 @@
+package url
+
+import (
+ "errors"
+ "strings"
+)
+
+type Websites_t []string
+
+type UserParams struct {
+ Websites Websites_t
+ Timeout int
+ Retry bool
+}
+
+func (u *UserParams) NewWebsite(w string) (*Websites_t, error) {
+ if !strings.HasPrefix(w, "http://") || !strings.HasPrefix(w, "https://") {
+ return &(*u).Websites, errors.New("url entered is not an http or https url")
+ }
+
+ u.Websites[len((*u).Websites)] = w
+
+ return &(*u).Websites, nil
+}
+
+func (u *UserParams) GetWebsites() (*Websites_t, error) {
+ if (*u).Websites == nil {
+ return nil, errors.New("no websites given in user params")
+ }
+
+ return &(*u).Websites, nil
+}