Class TerminalEndpoints
TerminalMixin delegates to these; an application that wants its own paths writes @RestGet methods
that call them and gets the same validation, cap and headers.
Bytes headers:
Term-Next: the offset to ask for next.Term-End: the source's current end.Term-Done:trueonce the producer is finished and the reader is at the end.Term-Cols,Term-Rows: the producer's terminal size.Term-Truncated:truewhen the bytes start later thanfrom.Term-Error: only evergone, when the log disappeared.
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidbytes(Optional<TerminalSource> source, RestRequest req, RestResponse res) Serves?from=<offset>&max=<n>as raw bytes with theTerm-*headers.static StringChecks a terminal id against^[A-Za-z0-9_-]{1,128}$.static voidraw(Optional<TerminalSource> source, String id, RestResponse res) Serves every byte still held as an attachment named<id>.log.static HttpResourcescript()The terminal runtime.static HttpResourceThe terminal stylesheet.static StringterminalAssetUrl(RestRequest req, String path) Returns the absolute URL of a terminal asset, resolved against the request, with a?v=<buildVersion>-<hash8>cache-buster.
-
Method Details
-
checkId
Checks a terminal id against^[A-Za-z0-9_-]{1,128}$.- Parameters:
id- The id from the URL path.- Returns:
- The same id.
- Throws:
BadRequest- If the id does not match.
-
bytes
public static void bytes(Optional<TerminalSource> source, RestRequest req, RestResponse res) throws IOException Serves?from=<offset>&max=<n>as raw bytes with theTerm-*headers.Answers
404for an empty source,400for a malformedfromormax,416withTerm-Endwhenfromis past the end, and otherwise200. Afromequal to the end is a200with no bytes.A gone source answers
200with no bytes,Term-Done: trueandTerm-Error: gone, whateverfromis. ItsTerm-NextandTerm-Endarefromitself, so a client that keeps polling never rewinds; the chunk's own offsets are not consulted.- Parameters:
source- The resolved source; empty answers404.req- The request.res- The response.- Throws:
IOException- If the source could not be read or the response written.
-
raw
public static void raw(Optional<TerminalSource> source, String id, RestResponse res) throws IOException Serves every byte still held as an attachment named<id>.log.A gone source still answers
200with an empty body, and carriesTerm-Error: goneasbytesdoes.The download is not capped and takes no range: it streams the whole log,
TerminalSource.MAX_READ_BYTESat a time, up to the end at the time of the request. The id is checked here as well as byTerminalMixin, because it becomes the file name.- Parameters:
source- The resolved source; empty answers404.id- The terminal id (also the download file name).res- The response.- Throws:
IOException- If the source could not be read or the response written.
-
script
The terminal runtime.- Returns:
juneau-terminal.jsas a JavaScriptHttpResource.
-
stylesheet
The terminal stylesheet.- Returns:
juneau-terminal.cssas a CSSHttpResource.
-
terminalAssetUrl
Returns the absolute URL of a terminal asset, resolved against the request, with a?v=<buildVersion>-<hash8>cache-buster.- Parameters:
req- The current request.path-TerminalMixin.JS_PATHorTerminalMixin.CSS_PATH.- Returns:
- The asset URL.
- Throws:
IllegalArgumentException- If this module does not ship the given path.
-