The {@link oaj.http.response} package contains predefined org.apache.http.HttpResponse implementations for most standard HTTP
responses.
- {@link oaj.http.response.Accepted}
- {@link oaj.http.response.AlreadyReported}
- {@link oaj.http.response.BadRequest}
- {@link oaj.http.response.Conflict}
- {@link oaj.http.response.Continue}
- {@link oaj.http.response.Created}
- {@link oaj.http.response.EarlyHints}
- {@link oaj.http.response.ExpectationFailed}
- {@link oaj.http.response.FailedDependency}
- {@link oaj.http.response.Forbidden}
- {@link oaj.http.response.Found}
- {@link oaj.http.response.Gone}
- {@link oaj.http.response.HttpVersionNotSupported}
- {@link oaj.http.response.IMUsed}
- {@link oaj.http.response.InsufficientStorage}
- {@link oaj.http.response.InternalServerError}
- {@link oaj.http.response.LengthRequired}
- {@link oaj.http.response.Locked}
- {@link oaj.http.response.LoopDetected}
- {@link oaj.http.response.MethodNotAllowed}
- {@link oaj.http.response.MisdirectedRequest}
- {@link oaj.http.response.MovedPermanently}
- {@link oaj.http.response.MultipleChoices}
- {@link oaj.http.response.MultiStatus}
- {@link oaj.http.response.NetworkAuthenticationRequired}
- {@link oaj.http.response.NoContent}
- {@link oaj.http.response.NonAuthoritiveInformation}
- {@link oaj.http.response.NotAcceptable}
- {@link oaj.http.response.NotExtended}
- {@link oaj.http.response.NotFound}
- {@link oaj.http.response.NotImplemented}
- {@link oaj.http.response.NotModified}
- {@link oaj.http.response.Ok}
- {@link oaj.http.response.PartialContent}
- {@link oaj.http.response.PayloadTooLarge}
- {@link oaj.http.response.PermanentRedirect}
- {@link oaj.http.response.PreconditionFailed}
- {@link oaj.http.response.PreconditionRequired}
- {@link oaj.http.response.Processing}
- {@link oaj.http.response.RangeNotSatisfiable}
- {@link oaj.http.response.RequestHeaderFieldsTooLarge}
- {@link oaj.http.response.ResetContent}
- {@link oaj.http.response.SeeOther}
- {@link oaj.http.response.ServiceUnavailable}
- {@link oaj.http.response.SwitchingProtocols}
- {@link oaj.http.response.TemporaryRedirect}
- {@link oaj.http.response.TooManyRequests}
- {@link oaj.http.response.Unauthorized}
- {@link oaj.http.response.UnavailableForLegalReasons}
- {@link oaj.http.response.UnprocessableEntity}
- {@link oaj.http.response.UnsupportedMediaType}
- {@link oaj.http.response.UpgradeRequired}
- {@link oaj.http.response.UriTooLong}
- {@link oaj.http.response.UseProxy}
- {@link oaj.http.response.VariantAlsoNegotiates}
These are built upon existing HttpComponents APIs:
- {@code org.apache.http.HttpMessage}
- {@code org.apache.http.HttpResponse}
- {@link oaj.http.response.BasicHttpResponse} - 100-399 response codes
- {@link oaj.http.response.BasicHttpException} - 400+ response codes
The most common location where these responses are used are in REST operation methods described later.
| @RestDelete(path="/{id}")
| public Ok doDelete(@Path int id) throws NotFound, Unauthorized {
| pojoService.delete(pojoService.find(id).orElseThrow(NotFound::new));
| return Ok.OK;
| }
The following classes are also provided for constructing your own custom responses:
- {@link oaj.http.response.BasicHttpException}
- {@link oaj.http.response.BasicHttpResponse}
- {@link oaj.http.response.HttpExceptionBuilder}
- {@link oaj.http.response.HttpResponseBuilder}
HttpResponseBuilder / HttpExceptionBuilder
HTTP responses are created through builders created in the {@link oaj.http.HttpResponses} class or individual create() methods
defined in the basic classes above. The builder contains the following methods:
- {@link oaj.http.response.HttpResponseBuilder}
- {@link oaj.http.response.HttpResponseBuilder#content(HttpEntity) content(HttpEntity)}
- {@link oaj.http.response.HttpResponseBuilder#content(String) content(String)}
- {@link oaj.http.response.HttpResponseBuilder#copyFrom(HttpResponse) copyFrom(HttpResponse)}
- {@link oaj.http.response.HttpResponseBuilder#getHeaders() getHeaders()}
- {@link oaj.http.response.HttpResponseBuilder#getStatusLine() getStatusLine()}
- {@link oaj.http.response.HttpResponseBuilder#header(Header) header(Header)}
- {@link oaj.http.response.HttpResponseBuilder#header(String,String) header(String,String)}
- {@link oaj.http.response.HttpResponseBuilder#headers(Header...) headers(Header...)}
- {@link oaj.http.response.HttpResponseBuilder#headers(HeaderList) headers(HeaderList)}
- {@link oaj.http.response.HttpResponseBuilder#headers(List) headers(List<Header>)}
- {@link oaj.http.response.HttpResponseBuilder#locale(Locale) locale(Locale)}
- {@link oaj.http.response.HttpResponseBuilder#location(String) location(String)}
- {@link oaj.http.response.HttpResponseBuilder#location(URI) location(URI)}
- {@link oaj.http.response.HttpResponseBuilder#protocolVersion(ProtocolVersion) protocolVersion(ProtocolVersion)}
- {@link oaj.http.response.HttpResponseBuilder#reasonPhrase(String) reasonPhrase(String)}
- {@link oaj.http.response.HttpResponseBuilder#reasonPhraseCatalog(ReasonPhraseCatalog) reasonPhraseCatalog(ReasonPhraseCatalog)}
- {@link oaj.http.response.HttpResponseBuilder#statusCode(int) statusCode(int)}
- {@link oaj.http.response.HttpResponseBuilder#statusLine(BasicStatusLine) statusLine(BasicStatusLine)}
- {@link oaj.http.response.HttpResponseBuilder#unmodifiable() unmodifiable()}