This is part 3 of a series of blog posts in which I walk through the creation of a simple chat app with Solace PubSub+. In the first part, I explained how to create a simple chat app that can send and receive messages via a direct topic subscription. In the second I explained how to modify the sample code so the application consumes messages from a queue. In this part, I’ll explain how to send a REST POST request from a login page to a dummy authentication service fronted by Solace PubSub+.
Specifically, you will:
Prerequisites
Level
By adding a server URL, you define where the REST POST request is sent to. To add a server URL, do the following:
git checkout remotes/origin/developer-exercise-3 -f
src > main > resources > static > scripts
//Enter serverUrl var serverUrl = ‘http://localhost:8081/solace/cloud/proxy’,
This URL sends the request through our web application server, which sends it to our Solace instance.
The fetch method defines how information is obtained from the server. Do the following to add the method and headers parameters:
//Complete fetch parameters; method and headers fetch(serverUrl, { method: “POST”,
headers: { “Content-Type”: “application/json; charset=utf-8”,
This tells the receiving server to deal with the REST message content in JSON format with the UTF-8 character encoding.
mvn spring-boot:run
to run the application.You have added login functionalities to the Web application to send a REST POST request to Solace PubSub+.
In the next part of the series, you will learn how to add a simple authentication server.