func (a *API) Get(ctx context.Context, req *http.Request) api.Response {
	defer req.Body.Close()
	d, err := api.GetDaemon(ctx)
	if err != nil {
		return api.InternalError(err)
	}
	tasks := make(map[string]Task)
	if err := d.Schedules().Walk(func(tsk schedules.Tsk) error {
		tasks[tsk.ID] = Task{
			ID:         tsk.ID,
			URL:        fmt.Sprintf("/%s%s", d.Version(), tsk.URL),
			Query:      tsk.Query,
			Schedule:   tsk.Schedule,
			Status:     tsk.Status,
			StatusCode: tsk.StatusCode.Raw(),
			Result:     tsk.Result,
			Err:        tsk.Err,
		}
		return nil
	}); err != nil {
		return api.SmartError(err)
	}
	result := make([]Task, len(tasks))
	var i int
	for _, v := range tasks {
		result[i] = v
		i++
	}
	sort.Slice(result, func(i, j int) bool {
		return result[i].Schedule.Before(result[j].Schedule)
	})
	return api.SyncResponse(true, result)
}
Get defines a service for calling "GET" method and returns a response.
package schedules
import (
	"context"
	"encoding/json"
	"fmt"
	"net/http"
	"sort"
	"time"
	"github.com/go-kit/kit/log"
	"github.com/pborman/uuid"
	"github.com/spoke-d/thermionic/internal/schedules"
	"github.com/spoke-d/thermionic/pkg/api"
)
type Task struct {
	ID         string    `json:"id" yaml:"id"`
	URL        string    `json:"url" yaml:"url"`
	Query      string    `json:"query" yaml:"query"`
	Schedule   time.Time `json:"schedule" yaml:"schedule"`
	Status     string    `json:"status" yaml:"status"`
	StatusCode int       `json:"status_code" yaml:"status_code"`
	Result     string    `json:"result" yaml:"result"`
	Err        string    `json:"err" yaml:"err"`
}
type API struct {
	api.DefaultService
	name   string
	logger log.Logger
}
func NewAPI(name string, options ...Option) *API {
	opts := newOptions()
	for _, option := range options {
		option(opts)
	}
	return &API{
		name:   name,
		logger: opts.logger,
	}
}
func (a *API) Name() string {
	return a.name
}