Interface ServerCallback
- All Superinterfaces:
FunctionPointer
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Functional interface declaration of the ServerCallback callback.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionvoidA callback used to handle requests to aServer.default MemorySegmenttoCallback(Arena arena) Creates a native function pointer to theupcall(MemorySegment, MemorySegment, MemorySegment, MemorySegment, MemorySegment)method.default voidupcall(MemorySegment server, MemorySegment msg, MemorySegment path, MemorySegment query, MemorySegment userData) Theupcallmethod is called from native code.
-
Method Details
-
run
A callback used to handle requests to a
Server.pathandquerycontain the likewise-named components of the Request-URI, subject to certain assumptions. By default,Serverdecodes all percent-encoding in the URI path, such that"/foo%2Fbar"is treated the same as"/foo/bar". If your server is serving resources in some non-POSIX-filesystem namespace, you may want to distinguish those as two distinct paths. In that case, you can set theServer:raw-pathsproperty when creating theServer, and it will leave those characters undecoded.querycontains the query component of the Request-URI parsed according to the rules for HTML form handling. Although this is the only commonly-used query string format in HTTP, there is nothing that actually requires that HTTP URIs use that format; if your server needs to use some other format, you can just ignorequery,and callMessage.getUri()and parse the URI's query field yourself.See
Server.addHandler(String, ServerCallback)andServer.addEarlyHandler(String, ServerCallback)for details of what handlers can/should do.- Parameters:
server- theSoupServermsg- the message being processedpath- the path component ofmsg'sRequest-URIquery- the parsed query component ofmsg'sRequest-URI
-
upcall
default void upcall(MemorySegment server, MemorySegment msg, MemorySegment path, MemorySegment query, MemorySegment userData) Theupcallmethod is called from native code. The parameters are marshaled andrun(Server, ServerMessage, String, HashTable)is executed. -
toCallback
Creates a native function pointer to theupcall(MemorySegment, MemorySegment, MemorySegment, MemorySegment, MemorySegment)method.- Specified by:
toCallbackin interfaceFunctionPointer- Parameters:
arena- the arena in which the function pointer is allocated- Returns:
- the native function pointer
-