diff --git a/README.md b/README.md index d2e43f1..153c405 100644 --- a/README.md +++ b/README.md @@ -71,3 +71,13 @@ GET /job/{uuid}/download Download the resulting archive (You may specify an ``` All routes accept the `log-on-error` parameter: If set a PDF download (`Accept` header set to `application/pdf`) will return the log instead of the PDF if no PDF is found. + +Providing `report-urls` parameter to the `POST /jobs` endpoint will not redirect to the wait endpoint but report a JSON object containing the URL paths: + +```json +{ + "download": "/job/fb5ee7b8-679a-4bf2-951b-acabaf43b43e/download", + "status": "/job/fb5ee7b8-679a-4bf2-951b-acabaf43b43e", + "wait": "/job/fb5ee7b8-679a-4bf2-951b-acabaf43b43e/wait" +} +``` diff --git a/processing.go b/processing.go index 4880d35..b8b419e 100644 --- a/processing.go +++ b/processing.go @@ -3,6 +3,7 @@ package main import ( "archive/zip" "bytes" + "encoding/json" "io" "math" "net/http" @@ -133,6 +134,18 @@ func startNewJob(res http.ResponseWriter, r *http.Request) { u := urlMust(router.Get("waitForJob").URL("uid", jobUUID.String())) u.RawQuery = r.URL.Query().Encode() + + if r.URL.Query().Has("report-urls") { + if err := json.NewEncoder(res).Encode(map[string]string{ + "download": urlMust(router.Get("downloadAssets").URL("uid", jobUUID.String())).String(), + "status": urlMust(router.Get("getJobStatus").URL("uid", jobUUID.String())).String(), + "wait": urlMust(router.Get("waitForJob").URL("uid", jobUUID.String())).String(), + }); err != nil { + serverErrorf(res, err, "encoding url response") + } + return + } + http.Redirect(res, r, u.String(), http.StatusFound) }