Skip to content

Commit

Permalink
Added deprecation warning for some methods in responses.d
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewlalis committed Jun 29, 2024
1 parent 9b72bdf commit 5896393
Showing 1 changed file with 25 additions and 23 deletions.
48 changes: 25 additions & 23 deletions source/handy_httpd/components/responses.d
Original file line number Diff line number Diff line change
Expand Up @@ -7,33 +7,35 @@ import handy_httpd.components.response;
import handy_httpd.components.handler : HttpRequestContext;
import streams;

void respond(
ref HttpResponse response,
HttpStatus status,
InputStream!ubyte bodyInputStream,
ulong bodySize,
string bodyContentType
) {
response.setStatus(status);
if (bodyInputStream !is null) {
response.writeBody(bodyInputStream, bodySize, bodyContentType);
deprecated("Use methods available directly from HttpResponse instead.") {
void respond(
ref HttpResponse response,
HttpStatus status,
InputStream!ubyte bodyInputStream,
ulong bodySize,
string bodyContentType
) {
response.setStatus(status);
if (bodyInputStream !is null) {
response.writeBody(bodyInputStream, bodySize, bodyContentType);
}
}
}

void respond(
ref HttpResponse response,
HttpStatus status,
string bodyContent,
string bodyContentType = "text/plain; charset=utf-8"
) {
response.setStatus(status);
if (bodyContent !is null && bodyContent.length > 0) {
response.writeBodyString(bodyContent, bodyContentType);
void respond(
ref HttpResponse response,
HttpStatus status,
string bodyContent,
string bodyContentType = "text/plain; charset=utf-8"
) {
response.setStatus(status);
if (bodyContent !is null && bodyContent.length > 0) {
response.writeBodyString(bodyContent, bodyContentType);
}
}
}

void respond(ref HttpResponse response, HttpStatus status) {
respond(response, status, null);
void respond(ref HttpResponse response, HttpStatus status) {
respond(response, status, null);
}
}

/**
Expand Down

0 comments on commit 5896393

Please sign in to comment.