2016-12-13 22:22:05 +00:00
|
|
|
package service
|
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/json"
|
|
|
|
"net/http"
|
|
|
|
|
|
|
|
"golang.org/x/net/context"
|
|
|
|
)
|
|
|
|
|
2016-12-15 01:22:17 +00:00
|
|
|
func decodeScheduleQueryRequest(ctx context.Context, r *http.Request) (interface{}, error) {
|
|
|
|
var req scheduleQueryRequest
|
2016-12-13 22:22:05 +00:00
|
|
|
|
|
|
|
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return req, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func decodeModifyScheduledQueryRequest(ctx context.Context, r *http.Request) (interface{}, error) {
|
|
|
|
id, err := idFromRequest(r, "id")
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
var req modifyScheduledQueryRequest
|
|
|
|
|
|
|
|
if err := json.NewDecoder(r.Body).Decode(&req.payload); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
req.ID = id
|
|
|
|
return req, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func decodeDeleteScheduledQueryRequest(ctx context.Context, r *http.Request) (interface{}, error) {
|
|
|
|
id, err := idFromRequest(r, "id")
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
var req deleteScheduledQueryRequest
|
|
|
|
req.ID = id
|
|
|
|
return req, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func decodeGetScheduledQueryRequest(ctx context.Context, r *http.Request) (interface{}, error) {
|
|
|
|
id, err := idFromRequest(r, "id")
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
var req getScheduledQueryRequest
|
|
|
|
req.ID = id
|
|
|
|
return req, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func decodeGetScheduledQueriesInPackRequest(ctx context.Context, r *http.Request) (interface{}, error) {
|
|
|
|
id, err := idFromRequest(r, "id")
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
var req getScheduledQueriesInPackRequest
|
|
|
|
req.ID = id
|
|
|
|
return req, nil
|
|
|
|
}
|