<aside> <img src="attachment:a3a56fc3-c53c-47ff-aacc-d7c34f62abfd:table_of_content.png" alt="attachment:a3a56fc3-c53c-47ff-aacc-d7c34f62abfd:table_of_content.png" width="40px" />
TABLE OF CONTENT
</aside>
| Package | ‣ dev.tommasop1804.springutils.reactive.request |
|---|---|
| Since version | 2.0.0 |
| JVM class name | ReactiveRequestUtilsKt |
ServerRequest.header(String)| Since version | 2.0.0 |
|---|---|
| Returns | :ij-kt-interface: List<String> |
| Parameters | • name: :ij-kt-class: String → the name of the header to retrieve |
Retrieves the values of the specified header from the server request.
ServerRequest.headerOrThrow(String, KClass<*>, (() -> Throwable)~)| Since version | 2.0.0 |
|---|---|
| Returns | :ij-kt-class: String |
| Parameters | • name: :ij-kt-class: String → the name of the header to retrieve |
• class: :ij-kt-interface: KClass<*> → the expected type class of the header, used for informational purposes when the exception is thrown |
|
• lazyException: ‣ () -> Throwable (default: { RequiredHeaderException(name, class) }) → a supplier function to create the exception to be thrown if the header is missing |
Retrieves the value of a header by its name or throws an exception if it is missing.
This method attempts to fetch the specified query parameter from the request. If the header is not found, it throws a lazily created exception provided by the lazyException parameter.
ServerRequest.headerOrThrow(String, KClass<*>, String)| Since version | 2.0.0 |
|---|---|
| Returns | :ij-kt-class: String |
| Parameters | • name: :ij-kt-class: String → the name of the header to retrieve |
• class: :ij-kt-interface: KClass<*> → the expected type class of the header, used for informational purposes when the exception is thrown |
|
• internalErrorCode: :ij-kt-class: String → an internal error code that adds context to the thrown exception |
|
| Exceptions | RequiredHeaderException → if the header is not present in the request |
Retrieves the value of a header by its name or throws an exception if it is missing.
This method attempts to fetch the specified header from the request. If the header is not found, it throws a RequiredHeaderException with the provided internal error code.
ServerRequest.headerOrDefault(String, () -> Any)| Since version | 2.0.0 |
|---|---|
| Returns | :ij-kt-class: String |
| Parameters | • name: :ij-kt-class: String → the name of the header to retrieve |
• default: ‣ () -> Any → a supplier that provides a default value if the header is not found |
Retrieves the header value associated with the given name or, if not present, returns a default value provided by the given supplier.
<aside> <img src="attachment:f407d415-108c-4b0e-a5a9-7c1df3b59a9c:plus.png" alt="attachment:f407d415-108c-4b0e-a5a9-7c1df3b59a9c:plus.png" width="40px" />
There are other functions that use ServerRequest as a receiver, and are specialized to return some headers:
accept(): :ij-kt-interface: List<String>acceptCharset(): :ij-kt-interface: List<String>acceptEncoding(): :ij-kt-interface: List<String>acceptLanguage(): :ij-kt-interface: List<String>acceptRanges(): :ij-kt-interface: List<String>connection(): :ij-kt-enum: ConnectionBehaviour? (KEEP_ALIVE, CLOSE)contentLength(): :ij-kt-class: RMeasurement<DataSizeUnit>? (KEEP_ALIVE, CLOSE)contentType(): :ij-kt-class: MediaType?expect(): :ij-kt-class: String?fromService(): :ij-kt-class: String?host(): :ij-kt-class: String?ifMatch(): :ij-kt-interface: List<String>ifModifiedSince(): :ij-java-class: Instant?ifNoneMatch(): :ij-kt-interface: List<String>ifRange(): :ij-kt-interface: List<String>ifUnmodifiedSince(): :ij-java-class: Instant?jwtToken(headerName: String = "Authorization"): :ij-kt-class: Jwt?origin(): :ij-kt-class: String?prefer(): :ij-kt-interface: List<String>priority(): :ij-kt-interface: List<String>range(): :ij-kt-interface: List<String>referer(): :ij-java-class: URL?
</aside>ServerRequest.pathVariableOrThrow(String, KClass<*>, (() -> Throwable)~)| Since version | 2.0.0 |
|---|---|
| Returns | :ij-kt-class: String |
| Parameters | • name: :ij-kt-class: String → the name of the path variable to retrieve |
• class: :ij-kt-interface: KClass<*> → the expected type class of the path variable, used for informational purposes when the exception is thrown |
|
• lazyException: ‣ () -> Throwable (default: { [RequiredPathVariableException](<https://tommasop1804.notion.site/Exceptions-32e8b91677358085b9afdf3ff98936ea>)(name, class) }) → a supplier function to create the exception to be thrown if the path variable is missing |
Retrieves the value of a path variable by its name or throws an exception if it is missing.
This method attempts to fetch the specified path variable from the request. If the parameter is not found, it throws a lazily created exception provided by the lazyException parameter.
ServerRequest.pathVariableOrThrow(String, KClass<*>, String)| Since version | 2.0.0 |
|---|---|
| Returns | :ij-kt-class: String |
| Parameters | • name: :ij-kt-class: String → the name of the path variable to retrieve |
• class: :ij-kt-interface: KClass<*> → the expected type class of the path variable, used for informational purposes when the exception is thrown |
|
• internalErrorCode: :ij-kt-class: String → an internal error code that adds context to the thrown exception |
|
| Exceptions | RequiredPathVariableException → if the path variable is not present in the request |
Retrieves the value of a path variable by its name or throws an exception if it is missing.
This method attempts to fetch the specified path variable from the request. If the variable is not found, it throws a RequiredPathVariableException with the provided internal error code.
ServerRequest.pathVariableOrDefault(String, () -> Any)| --- | --- |