Description
Right now, there are only two APIs that allows plugins to set the HTTP status code and body message:
tsapi void TSHttpTxnSetHttpRetBody(TSHttpTxn txnp, const char* body_msg, int plain_msg); tsapi void TSHttpTxnSetHttpRetStatus(TSHttpTxn txnp, TSHttpStatus http_retstatus);
Since the body factory ("templates") are now the only way to produce error messages from within ATS itself, these APIs are now lacking a way to specify which template to use. I imagine three possibilities (at least):
1) Make the last argument to TSHttpTxnSetHttpRetBody() be a multi-value variable, with the semantics of
0 - body is HTML
1 - body is plain text
2 - body is a factory template name (e.g. "access#denied" or "shrek#ogre").
This is probably pretty safe, but perhaps not super pretty.
2) Make TSHttpTxnSetHttpRetStatus() also take a body factory argument, e.g.
tsapi void TSHttpTxnSetHttpRetStatus(TSHttpTxn txnp, TSHttpStatus http_retstatus, const char* factory);
factory should probably be a string here, and not constants, because users can put in arbitrary file names into the body factory. The string really is the filename. This would break compatibility of the APIs I think.
3) We add a new API, e.g.
tsapi void TSHttpTxnSetHttpFactory(TSHttpTxn txnp, const char* factory);