KrosstalkEndpoint
Specifies an endpoint for the krosstalk method to use. endpoint should be a http-formatted string of the (relative) pathname and query string, i.e. "/items/?id={id}"
. Supported syntax is as follows:
Literals
Parameters:
{param}
.Parameter with name:
{{param}}
, becomes/param/{param}
orparam={param}
depending on location.Optional:
[?param:...]
. Evaluates to the body (...
) if param is present (not null ifname
is a nullable@Optional
or not a default ifname
is aServerDefault
@Optional
), empty otherwise. Contents are treated as full segments, i.e.my[?param:id]={param2}
is not allowed.Optional named parameter:
{{?param}}
, becomes{{param}}
if param is present, empty otherwise.
For both optionals, param
must either be @Optional
.
Valid parameter names are the method parameters, instanceReceiver if it has an instance/dispatch receiver, extensionReceiver if it has a extension receiver.
krosstalkPrefix and methodName may be used as literals, they evaluate to the Krosstalk's Krosstalk.prefix and the method's name (including the signature hash), respectively.
All 4 of these special parameters may be included by using the constant in string interpolation, like "$methodName"
, or by escaping the $
like "\$methodName"
. This is because the value of each constant is it's name with '$'
prepended.
The default endpoint is thus "$krosstalkPrefix/$methodName"
.
URL parameters will be evaluated by serializing the argument using the Krosstalk's Krosstalk.urlSerialization (which by default is the same as the body). I highly recommend setting it to something string-based like JSON. If you want to include non-trivial functions of the arguments in the endpoint, include them in the function as default arguments and use those.
Parameters that are present in the URL whenever they are not null will not be passed in the body, and will instead be deserialized from the URL.
httpMethod controls the HTTP method used by requests. If it is GET
, the function must have no parameters or use EmptyBody.
contentType controls the content type of the request and response. If empty (which is default), the Krosstalk object's serialization handler's SerializationHandler.contentType is used. May not be used for non-success results when used with ExplicitResult. This setting is a recommendation, which may be ignored by the client in some cases. Servers should almost always use it, but may not in some corner cases.