742efb6ff310c75a30cf13088111139cf713b9db angie Tue Feb 23 11:06:52 2016 -0800 Unifying some triplicate code to print an HTTP error 400 response (Bad Request) and exit. diff --git src/hg/hgGtexApi/hgGtexApi.c src/hg/hgGtexApi/hgGtexApi.c index 1dcc43f..9d0fe8b 100644 --- src/hg/hgGtexApi/hgGtexApi.c +++ src/hg/hgGtexApi/hgGtexApi.c @@ -1,28 +1,29 @@ /* Copyright (C) 2015 The Regents of the University of California * See README in this or parent directory for licensing information. */ /* hgGtexApi - a web API to selected GTEx resources * * usage: http://hgwdev-kate.cse.ucsc.edu/cgi-bin/hgGtexApi?gene=ENSG00000223972.4 * * returns JSON in the format: * { "id": , "tissue": , "rpkm": } */ #include "common.h" #include "hdb.h" +#include "htmshell.h" #include "hPrint.h" #include "dystring.h" #include "api.h" #include "gtexSampleData.h" /* Requests */ // TODO: Move to lib void gtexSampleDataJson(struct dyString *json, struct gtexSampleData *data) /* Print out gtexSampleData in JSON format. */ { dyStringPrintf(json, "{"); dyStringPrintf(json, "\"sample\":\"%s\"", data->sample); dyStringPrintf(json, ", "); @@ -55,24 +56,24 @@ dyStringAppend(output,",\n"); } output->string[dyStringLen(output)-2] = '\n'; output->string[dyStringLen(output)-1] = ']'; dyStringPrintf(output, "\n"); sqlDisconnect(&conn); } int main(int argc, char *argv[]) /* Process command line */ { long enteredMainTime = clock1000(); struct dyString *output = newDyString(10000); cgiSpoof(&argc, argv); -pushWarnHandler(apiWarnAbortHandler); -pushAbortHandler(apiWarnAbortHandler); +pushWarnHandler(htmlVaBadRequestAbort); +pushAbortHandler(htmlVaBadRequestAbort); char *jsonp = cgiOptionalString("jsonp"); geneResource(output); apiOut(dyStringContents(output), jsonp); cgiExitTime("hgGtexApi", enteredMainTime); return 0; }