-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathhandlers.go
54 lines (45 loc) · 880 Bytes
/
handlers.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
package main
import (
"net/http"
"github.com/labstack/echo/v4"
)
type (
// Project is a fetch project
Project struct {
StartDate string `json:"startDate"`
EndDate string `json:"endDate"`
}
// Task is task info
Task struct {
*Project
Pages []int `json:"pages"`
}
// Result is task result
Result struct {
*Project
Page int `json:"page"`
Content string `json:"content"`
}
)
var (
maxPage = 964391
proj = &Project{
StartDate: "2000.01.01",
EndDate: "2019.12.31",
}
)
func applyForTask(c echo.Context) error {
task := &Task{
Project: proj,
Pages: fetcherInfo.assignPages(3, maxPage),
}
return c.JSON(http.StatusOK, task)
}
func submitTaskResult(c echo.Context) (err error) {
res := new(Result)
if err = c.Bind(res); err != nil {
return
}
fetcherInfo.resultsChannel <- res
return c.NoContent(http.StatusNoContent)
}