Package com.linecorp.armeria.server
Class AbstractHttpService
java.lang.Object
com.linecorp.armeria.server.AbstractHttpService
- All Implemented Interfaces:
Unwrappable,HttpService,Service<HttpRequest,HttpResponse>
- Direct Known Subclasses:
AbstractGraphqlService,AbstractUnsafeUnaryGrpcService,FileService,ManagementService,PrometheusExpositionService,PrometheusExpositionService
A skeletal
HttpService for easier HTTP service implementation.
This class provides the methods that handles the HTTP requests of the methods their names signify.
For example, doGet() method handles a
GET request.
doOptions(ServiceRequestContext, HttpRequest)doGet(ServiceRequestContext, HttpRequest)doHead(ServiceRequestContext, HttpRequest)doPost(ServiceRequestContext, HttpRequest)doPut(ServiceRequestContext, HttpRequest)doPatch(ServiceRequestContext, HttpRequest)doDelete(ServiceRequestContext, HttpRequest)doTrace(ServiceRequestContext, HttpRequest)
405 Method Not Allowed response
by default. Override one of them to handle requests properly.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected HttpResponsedoConnect(ServiceRequestContext ctx, HttpRequest req) Handles aCONNECTrequest.protected HttpResponsedoDelete(ServiceRequestContext ctx, HttpRequest req) Handles aDELETErequest.protected HttpResponsedoGet(ServiceRequestContext ctx, HttpRequest req) Handles aGETrequest.protected HttpResponsedoHead(ServiceRequestContext ctx, HttpRequest req) Handles aHEADrequest.protected HttpResponsedoOptions(ServiceRequestContext ctx, HttpRequest req) Handles anOPTIONSrequest.protected HttpResponsedoPatch(ServiceRequestContext ctx, HttpRequest req) Handles aPATCHrequest.protected HttpResponsedoPost(ServiceRequestContext ctx, HttpRequest req) Handles aPOSTrequest.protected HttpResponsedoPut(ServiceRequestContext ctx, HttpRequest req) Handles aPUTrequest.protected HttpResponsedoTrace(ServiceRequestContext ctx, HttpRequest req) Handles aTRACErequest.final HttpResponseserve(ServiceRequestContext ctx, HttpRequest req) Serves the specifiedHttpRequestby delegating it to the matching'doMETHOD()'method.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.linecorp.armeria.server.HttpService
decorate, decorate, exchangeType, optionsMethods inherited from interface com.linecorp.armeria.server.Service
as, serviceAdded, shouldCachePath, unwrapMethods inherited from interface com.linecorp.armeria.common.util.Unwrappable
equalsIgnoreWrapper, unwrapAll
-
Constructor Details
-
AbstractHttpService
public AbstractHttpService()
-
-
Method Details
-
serve
Serves the specifiedHttpRequestby delegating it to the matching'doMETHOD()'method.- Specified by:
servein interfaceHttpService- Specified by:
servein interfaceService<HttpRequest,HttpResponse> - Parameters:
ctx- the context of the receivedRequestreq- the receivedRequest- Returns:
- the
Response - Throws:
Exception
-
doOptions
Handles anOPTIONSrequest. This method sends a405 Method Not Allowedresponse by default.- Throws:
Exception
-
doGet
Handles aGETrequest. This method sends a405 Method Not Allowedresponse by default.- Throws:
Exception
-
doHead
Handles aHEADrequest. This method sends a405 Method Not Allowedresponse by default.- Throws:
Exception
-
doPost
Handles aPOSTrequest. This method sends a405 Method Not Allowedresponse by default.- Throws:
Exception
-
doPut
Handles aPUTrequest. This method sends a405 Method Not Allowedresponse by default.- Throws:
Exception
-
doPatch
Handles aPATCHrequest. This method sends a405 Method Not Allowedresponse by default.- Throws:
Exception
-
doDelete
Handles aDELETErequest. This method sends a405 Method Not Allowedresponse by default.- Throws:
Exception
-
doTrace
Handles aTRACErequest. This method sends a405 Method Not Allowedresponse by default.- Throws:
Exception
-
doConnect
Handles aCONNECTrequest. Note that Armeria handles only aCONNECTrequest with a:protocolHTTP/2 pseudo header, as defined in RFC8441, Bootstrapping WebSockets with HTTP/2. This method sends a405 Method Not Allowedresponse by default.- Throws:
Exception
-