Package org.yamcs.http
Class HandlerContext
java.lang.Object
org.yamcs.http.HandlerContext
-
Constructor Summary
ConstructorDescriptionHandlerContext
(String contextPath, io.netty.channel.ChannelHandlerContext ctx, io.netty.handler.codec.http.HttpRequest req, User user) -
Method Summary
Modifier and TypeMethodDescriptionio.netty.buffer.ByteBuf
String[]
getCredentials
(String type) getFormParameter
(String parameter) getHeader
(CharSequence name) io.netty.channel.ChannelHandlerContext
io.netty.handler.codec.http.FullHttpRequest
io.netty.handler.codec.http.HttpRequest
getParameter
(String parameter) getQueryParameter
(String parameter) Attempts to derive the externally used URL to Yamcs based on request informationgetUser()
boolean
boolean
isGET()
boolean
isPOST()
void
render
(io.netty.handler.codec.http.HttpResponseStatus status, String templateResource, Map<String, Object> vars) void
renderToString
(String templateResource, Map<String, Object> vars) void
requireFormParameter
(String parameter) void
void
requireMethod
(io.netty.handler.codec.http.HttpMethod... allowedMethods) requireParameter
(String parameter) void
requireQueryParameter
(String parameter) void
sendAllow
(io.netty.handler.codec.http.HttpMethod... methods) void
sendOK()
void
sendOK
(com.google.gson.JsonObject jsonObject) void
sendOK
(com.google.protobuf.Message message) void
sendRedirect
(String location) void
sendResource
(String resource) Send a classpath resource.io.netty.channel.ChannelFuture
sendResponse
(io.netty.handler.codec.http.HttpResponse response)
-
Constructor Details
-
HandlerContext
-
-
Method Details
-
getUser
-
getRequestBaseURL
Attempts to derive the externally used URL to Yamcs based on request information- Returns:
- a url of the form [protocol]://[host]:[port][context]
-
getOriginalHostAddress
-
getOriginalHostName
-
getNettyChannelHandlerContext
public io.netty.channel.ChannelHandlerContext getNettyChannelHandlerContext() -
getNettyHttpRequest
public io.netty.handler.codec.http.HttpRequest getNettyHttpRequest() -
getNettyFullHttpRequest
public io.netty.handler.codec.http.FullHttpRequest getNettyFullHttpRequest()- Throws:
ClassCastException
- if this context does not contain a "full" HTTP request.
-
getContextPath
-
getPathWithoutContext
-
isGET
public boolean isGET() -
isPOST
public boolean isPOST() -
requireGET
public void requireGET() -
requirePOST
public void requirePOST() -
requireMethod
public void requireMethod(io.netty.handler.codec.http.HttpMethod... allowedMethods) -
requireFormEncoding
public void requireFormEncoding() -
requireFormParameter
-
requireQueryParameter
-
requireParameter
-
getHeader
-
isFormEncoded
public boolean isFormEncoded() -
getCredentials
-
getBasicCredentials
-
getFormParameter
-
getQueryParameter
-
getParameter
-
createByteBuf
public io.netty.buffer.ByteBuf createByteBuf() -
renderOK
-
render
-
renderToString
-
sendOK
public void sendOK() -
sendOK
public void sendOK(com.google.protobuf.Message message) -
sendOK
public void sendOK(com.google.gson.JsonObject jsonObject) -
sendAllow
public void sendAllow(io.netty.handler.codec.http.HttpMethod... methods) -
sendResource
Send a classpath resource. -
sendResponse
public io.netty.channel.ChannelFuture sendResponse(io.netty.handler.codec.http.HttpResponse response) -
sendRedirect
-