Math Quote Microservice - barba93/CS361Assignment5 GitHub Wiki
This microservice provides a random quote from a mathematician when you make a simple HTTP GET request.
Communication Contract
This section outlines how to programmatically interact with the Math Quote Microservice.
Requesting Data
To request a random math quote, you need to make an HTTP GET request to the following endpoint:
https://microservicecarlos.azurewebsites.net/api/mathquote?
No authentication or request body is required.
Example Call (Conceptual):
The specific implementation will depend on the programming language or tool you are using. Here's a conceptual example of what a GET request would look like (you would not type this directly into a browser's address bar and expect to see the raw request, but this illustrates the HTTP method and URL):
GET /api/mathquote? HTTP/1.1 Host: microservicecarlos.azurewebsites.net
Many programming languages have built-in libraries to make HTTP requests. For example, in Python, you might use the requests
library:
import requests
response = requests.get("[https://microservicecarlos.azurewebsites.net/api/mathquote](https://microservicecarlos.azurewebsites.net/api/mathquote)?")
Receiving Data
The microservice will respond with plain text containing a single random quote from a mathematician.
Response Body:
The body of the HTTP response will be the quote itself.
Content-Type:
The Content-Type header in the response will be text/plain.
Example Call and Expected Response (Conceptual):
Request:
GET /api/mathquote? HTTP/1.1
Host: microservicecarlos.azurewebsites.net
Possible Response: Code snippet
HTTP/1.1 200 OK
Content-Type: text/plain; charset=utf-8
Content-Length:
The essence of mathematics lies in its freedom. - Georg Cantor
Programmatic Handling:
When you receive the response in your code, you will need to read the body of the response. This will be a string containing the quote.
Example (Python using requests): Python
import requests
url = "https://microservicecarlos.azurewebsites.net/api/mathquote?"
try:
response = requests.get(url)
response.raise_for_status()
print(response.text)
except requests.RequestException as e:
print(f"Failed to retrieve the file: {e}")