You are going to now see an example of an HTML representation that can load the JSON representation. The server must provide a link to the resource and a link to the code on demand.
When we request a page in a browser, it generally asks for HTML (this is called content negotiation) as the first representation that it wants. By building a server that responds to these requests we get two things:
The HTML that looks like this:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Resource</title>
<link rel="self" href="http://localhost:5000/" />
<link rel="me" href="http://localhost:5000/user/me" />
<link rel="authenticate" href="http://localhost:5000/authenticate" />
<link rel="tags" href="http://localhost:5000/tag" />
<link rel="users" href="http://localhost:5000/user" />
</head>
<body>
<div id="app">Intialising ...</div>
<script src="http://localhost:8080/api.js"></script>
</body>
</html>
Two lines in the HTML are highlighted:
self
which is the resource to be loaded which also is the URL in the address bar in the browser.<link rel="self" href="http://localhost:5000/" />
<script src="http://localhost:8080/api.js"></script>
This tutorial separates the ASP.NET Core C# code that generates this HTML and the javascript which is the api.js
).
Read here for more on understanding content negotiation values particularly in relation to q values.
This example shows that text/html
is the highest priority 0.9
(read 90%).