Nushell has very useful commands to filter lists and tables. When you have a list with null values, you can use the compact
command to filter out the null values. With the option --empty
you can also filter out empty items like empty strings, empty lists and empty records. If you want to filter out rows in a table where a column contains a null value, you can use the compact
command followed by the name of the column.
Continue reading →
Nushell has some nice built-in commands to get randomized data. The random
command can be used to get random numbers, strings, and more. You can use the dice
subcommand to get random numbers between 1 and 6. The command returns a list of integers. With the option --dice
you can specify how many times to throw the dice. By default the dice has 6 sides, but you can use the option --sides
to change that. You could roll a dice with 2 sides, like flipping a coin, or roll a dice with 10 sides.
Continue reading →
The nice thing about the http
command in Nushell is that you can interact with HTTP endpoints without the need to install any external tools. You can use several subcommands like get
, post
, put
, delete
and patch
. Each of these commands has the options to specify request headers. You can use the option --headers
or the short version -H
followed by a list of header keys and values.
Continue reading →
The http
command in Nushell can be used to interact with HTTP endpoints. You can post data to an endpoint using the post
subcommand. If you want to post JSON data than you can simply use a record data structure and use the argument --content-type application/json
(or the shorthand -t application/json
). Nushell will automatically convert the record data structure to JSON and use it as the body of the HTTP request.
Continue reading →
Nushell has a built-in command to invoke HTTP requests: http
. You don’t need an external tool like curl
or httpie
to make HTTP requests. There a lot of options to use with the http
command. One of them is the --full
or shorter -f
option to return a table with extra details of the HTTP request and response. The request and response headers, the body and status are returned in the table. You can easily get information from the table with all the default selection options for a table structure.
Continue reading →
Nushell has a lot of commands to work with strings. The str kebab-case
command can be used to convert a string to kebab case. Kebab-case is a string that contains only lowercase letters and words are separated by hyphens.
Continue reading →
SDKMAN! is as powerful tool to install and manage software development kits (SDKs) and tools, like Java, Groovy, Gradle, Maven, Spring Boot and Quarkus. If you want to see if a new version of a SDK or tool is available, you can use the sdk upgrade
command. This command will list all outdated SDKs and tools. The installed version and the latest version are shown for each SDK and tool. To see if a single SDK or tool is outdated, you can use the name of the SDK or tool as argument to the sdk upgrade
command.
Continue reading →
When you enable the /observe
endpoints you can configure them to be served on a different port than the application. By default the endpoints are available on the same port as the application. But you can define an extra named socket with another port number in the configuration of the WebServer
instance. And in the configuration of the ObserveFeature
instance you can define the socket name that should be used for the observe endpoints.
Continue reading →
In a previous post you learned how to add information to the /observe/info
endpoint. You can also add Git information to the endpoint. For example you can add the Git commit id so you can see check, when the application is running in a production environment, which Git commit for the code was deployed. In order to achieve this you must first generate a properties file with all Git information. The next step is to process this file in your Helidon SE application and add the properties to the /observe/info
endpoint.
Continue reading →
It is possible to add an endpoint to Helidon SE that can show information about the application. You can add custom information to this endpoint. In order to enable the endpoint you need to add the dependency io.helidon.webserver.observe:helidon-webserver-observe-info
to your pom.xml
file. This will add the endpoint /observe/info
to your application. You can add key-value pairs to your configuration or code that will be exposed in the endpoint.
Continue reading →
You can configure a memory health check in Helidon SE. A memory health check will return a status of UP
if the memory usage is below a certain threshold percentage and DOWN
if the memory usage is above the threshold percentage. The default threshold percentage is 98%
. To add the memory health check you need to add the dependency io.helidon.health:helidon-health-checks
to your pom.xml
file. This dependency contains three health checks: disk space usage, memory usage and dead lock detection.
To configure the memory health check you need to set the configuration property server.features.observe.observers.health.helidon.health.memory.thresholdPercent
to the threshold percentage. Alternatively you can set the threshold percentage in your application code.
Continue reading →
Suppose you want to return a response based on the Accept
header of the request. If the Accept
header is application/json
you want to return a JSON response and if the Accept
header is application/xml
you want to return an XML response. You can use the isAccepted(MediaType)
of the ServerRequestHeaders
class to check if the value of the request header Accept
is equal to the specified media type. The method returns true
if the media type is defined for the request header Accept
and false
if not.
In order to convert an object to XML you need to add the dependency com.fasterxml.jackson.dataformat:jackson-dataformat-xml
to your pom.xml
file:
Continue reading →