Package de.srsoftware.tools
Klasse PathHandler
java.lang.Object
de.srsoftware.tools.PathHandler
- Alle implementierten Schnittstellen:
HttpHandler
implementation of HttpHandler that attaches to a given path
-
Verschachtelte Klassen - Übersicht
Verschachtelte KlassenModifizierer und TypKlasseBeschreibungstatic final recordObject to hold auth dataclassthis class allows to bind a PathHandler to a HttpServer instance -
Feldübersicht
Felder -
Konstruktorübersicht
Konstruktoren -
Methodenübersicht
Modifizierer und TypMethodeBeschreibungstatic booleanbadRequest(HttpExchange ex, byte[] bytes) create a response with status code 400, send payloadstatic booleanbadRequest(HttpExchange ex, Object o) create a response with status code 400, send payloadBind the PathHandler object to one/several pathsstatic Stringbody(HttpExchange ex) extracts the body of an HttpExchangebooleandoDelete(String path, HttpExchange ex) "not found" default implementationbooleandoGet(String path, HttpExchange ex) "not found" default implementationbooleandoPost(String path, HttpExchange ex) "not found" default implementationextract the value of an Authorization header, if presentstatic Optional<PathHandler.BasicAuth> getHeader(HttpExchange ex, String key) voidhandle(HttpExchange ex) static Stringhostname(HttpExchange ex) static org.json.JSONObjectjson(HttpExchange ex) static Stringlanguage(HttpExchange ex) static booleannotFound(HttpExchange ex) static booleansendContent(HttpExchange ex, byte[] bytes) static booleansendContent(HttpExchange ex, int status, byte[] bytes) create a response given status code, send payloadstatic booleansendContent(HttpExchange ex, int status, Object o) create a response given status code, send payloadstatic booleansendContent(HttpExchange ex, Object o) static booleansendEmptyResponse(int statusCode, HttpExchange ex) static booleansendRedirect(HttpExchange ex, String url) static booleanserverError(HttpExchange ex, Object o) create a "internal server error" responsestatic Stringurl(HttpExchange ex) recover the URL from an HttpExchange object
-
Felddetails
-
AUTHORIZATION
- Siehe auch:
-
CONTENT_TYPE
- Siehe auch:
-
DEFAULT_LANGUAGE
- Siehe auch:
-
DELETE
- Siehe auch:
-
GET
- Siehe auch:
-
HOST
- Siehe auch:
-
JSON
- Siehe auch:
-
LOG
-
POST
- Siehe auch:
-
-
Konstruktordetails
-
PathHandler
public PathHandler()
-
-
Methodendetails
-
badRequest
create a response with status code 400, send payload- Parameter:
ex- the HttpExchange to write tobytes- the payload- Gibt zurück:
- true – result is only created to allow return badRequest(…)
- Löst aus:
IOException- if writing to the HttpEchange object fails
-
badRequest
create a response with status code 400, send payload- Parameter:
ex- the HttpExchange to write too- the payload- Gibt zurück:
- true – result is only created to allow return badRequest(…)
- Löst aus:
IOException- if writing to the HttpEchange object fails
-
bindPath
Bind the PathHandler object to one/several paths- Parameter:
path- the paths to bind to- Gibt zurück:
- a bond, that can be used to create a context on a HttpServer
-
doDelete
"not found" default implementation- Parameter:
path- ignoredex- HttpExchange used to return the not-implmented notification- Gibt zurück:
- false
- Löst aus:
IOException- if sending the response fails
-
doGet
"not found" default implementation- Parameter:
path- ignoredex- HttpExchange used to return the not-implmented notification- Gibt zurück:
- false
- Löst aus:
IOException- if sending the response fails
-
doPost
"not found" default implementation- Parameter:
path- ignoredex- HttpExchange used to return the not-implmented notification- Gibt zurück:
- false
- Löst aus:
IOException- if sending the response fails
-
handle
- Angegeben von:
handlein SchnittstelleHttpHandler- Löst aus:
IOException
-
relativePath
-
body
extracts the body of an HttpExchange- Parameter:
ex- the exchange to process- Gibt zurück:
- the content of the HttpExchange
- Löst aus:
IOException- if reading the body failed
-
getAuthToken
extract the value of an Authorization header, if present- Parameter:
ex- the HttpExchange to extract from- Gibt zurück:
- an optional, carrying the first value of an Authorization header, of present. empty, otherwise.
-
getBasicAuth
-
getBearer
-
getHeader
-
hostname
-
json
- Löst aus:
IOException
-
language
-
notFound
- Löst aus:
IOException
-
queryParam
-
sendEmptyResponse
- Löst aus:
IOException
-
sendRedirect
- Löst aus:
IOException
-
sendContent
create a response given status code, send payload- Parameter:
ex- the HttpExchange to write tostatus- the status codebytes- the payload- Gibt zurück:
- true – result is only created to allow return badRequest(…)
- Löst aus:
IOException- if writing to the HttpEchange object fails
-
sendContent
create a response given status code, send payload- Parameter:
ex- the HttpExchange to write tostatus- the status codeo- the payload- Gibt zurück:
- true – result is only created to allow return badRequest(…)
- Löst aus:
IOException- if writing to the HttpEchange object fails
-
sendContent
- Löst aus:
IOException
-
sendContent
- Löst aus:
IOException
-
serverError
create a "internal server error" response- Parameter:
ex- the HttpExchange objecto- an additional payload- Gibt zurück:
- false
- Löst aus:
IOException- if the content cannot be sent
-
url
recover the URL from an HttpExchange object- Parameter:
ex- the HttpExchange object- Gibt zurück:
- the url of this object
-