forked from datatogether/api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuncrawlable_requests.go
61 lines (50 loc) · 1.01 KB
/
uncrawlable_requests.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package main
import (
"github.com/datatogether/core"
)
type Uncrawlables int
type UncrawlablesGetParams struct {
Id string
Url string
}
func (u *Uncrawlables) Get(p *UncrawlablesGetParams, res *core.Uncrawlable) (err error) {
url := &core.Uncrawlable{
Id: p.Id,
Url: p.Url,
}
err = url.Read(store)
if err != nil {
return err
}
*res = *url
return nil
}
type UncrawlablesListParams struct {
OrderBy string
Limit int
Offset int
}
func (u *Uncrawlables) List(p *UncrawlablesListParams, res *[]*core.Uncrawlable) (err error) {
urls, err := core.ListUncrawlables(store, p.Limit, p.Offset)
if err != nil {
return err
}
*res = urls
return nil
}
func (u *Uncrawlables) Save(model *core.Uncrawlable, res *core.Uncrawlable) (err error) {
err = model.Save(store)
if err != nil {
return err
}
*res = *model
return nil
}
func (u *Uncrawlables) Delete(model *core.Uncrawlable, res *core.Uncrawlable) (err error) {
err = model.Delete(store)
if err != nil {
return err
}
*res = *model
return nil
}