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
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
-
Method Summary
Modifier and TypeMethodDescriptionprotected HttpResponse
doConnect
(ServiceRequestContext ctx, HttpRequest req) Handles aCONNECT
request.protected HttpResponse
doDelete
(ServiceRequestContext ctx, HttpRequest req) Handles aDELETE
request.protected HttpResponse
doGet
(ServiceRequestContext ctx, HttpRequest req) Handles aGET
request.protected HttpResponse
doHead
(ServiceRequestContext ctx, HttpRequest req) Handles aHEAD
request.protected HttpResponse
doOptions
(ServiceRequestContext ctx, HttpRequest req) Handles anOPTIONS
request.protected HttpResponse
doPatch
(ServiceRequestContext ctx, HttpRequest req) Handles aPATCH
request.protected HttpResponse
doPost
(ServiceRequestContext ctx, HttpRequest req) Handles aPOST
request.protected HttpResponse
doPut
(ServiceRequestContext ctx, HttpRequest req) Handles aPUT
request.protected HttpResponse
doTrace
(ServiceRequestContext ctx, HttpRequest req) Handles aTRACE
request.final HttpResponse
serve
(ServiceRequestContext ctx, HttpRequest req) Serves the specifiedHttpRequest
by delegating it to the matching'doMETHOD()'
method.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.linecorp.armeria.server.HttpService
decorate, decorate, exchangeType
Methods inherited from interface com.linecorp.armeria.server.Service
as, serviceAdded, shouldCachePath, unwrap
-
Constructor Details
-
AbstractHttpService
public AbstractHttpService()
-
-
Method Details
-
serve
Serves the specifiedHttpRequest
by delegating it to the matching'doMETHOD()'
method.- Specified by:
serve
in interfaceHttpService
- Specified by:
serve
in interfaceService<HttpRequest,
HttpResponse> - Parameters:
ctx
- the context of the receivedRequest
req
- the receivedRequest
- Returns:
- the
Response
- Throws:
Exception
-
doOptions
Handles anOPTIONS
request. This method sends a405 Method Not Allowed
response by default.- Throws:
Exception
-
doGet
Handles aGET
request. This method sends a405 Method Not Allowed
response by default.- Throws:
Exception
-
doHead
Handles aHEAD
request. This method sends a405 Method Not Allowed
response by default.- Throws:
Exception
-
doPost
Handles aPOST
request. This method sends a405 Method Not Allowed
response by default.- Throws:
Exception
-
doPut
Handles aPUT
request. This method sends a405 Method Not Allowed
response by default.- Throws:
Exception
-
doPatch
Handles aPATCH
request. This method sends a405 Method Not Allowed
response by default.- Throws:
Exception
-
doDelete
Handles aDELETE
request. This method sends a405 Method Not Allowed
response by default.- Throws:
Exception
-
doTrace
Handles aTRACE
request. This method sends a405 Method Not Allowed
response by default.- Throws:
Exception
-
doConnect
Handles aCONNECT
request. Note that Armeria handles only aCONNECT
request with a:protocol
HTTP/2 pseudo header, as defined in RFC8441, Bootstrapping WebSockets with HTTP/2. This method sends a405 Method Not Allowed
response by default.- Throws:
Exception
-