forked from datatogether/api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcustom_crawl_requests.go
59 lines (48 loc) · 1009 Bytes
/
custom_crawl_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
package main
import (
"github.com/datatogether/core"
)
type CustomCrawls int
type CustomCrawlsGetParams struct {
Id string
}
func (u *CustomCrawls) Get(p *CustomCrawlsGetParams, res *core.CustomCrawl) (err error) {
url := &core.CustomCrawl{
Id: p.Id,
}
err = url.Read(store)
if err != nil {
return err
}
*res = *url
return nil
}
type CustomCrawlsListParams struct {
OrderBy string
Limit int
Offset int
}
func (u *CustomCrawls) List(p *CustomCrawlsListParams, res *[]*core.CustomCrawl) (err error) {
urls, err := core.ListCustomCrawls(store, p.Limit, p.Offset)
if err != nil {
return err
}
*res = urls
return nil
}
func (u *CustomCrawls) Save(model *core.CustomCrawl, res *core.CustomCrawl) (err error) {
err = model.Save(store)
if err != nil {
return err
}
*res = *model
return nil
}
func (u *CustomCrawls) Delete(model *core.CustomCrawl, res *core.CustomCrawl) (err error) {
err = model.Delete(store)
if err != nil {
return err
}
*res = *model
return nil
}