Service Endpoints - an API

Introduction

A quick reference on creating service endpoints - an API

URL Structure

 

The root/home path is simply protocol + sub-domain + domain

An endpoint can simply be described as the protocol + sub-domain + domain + path



Setting Request Handlers

A Web Server receives Requests, processes them, and returns a Response.  We need to establish route handling in our application to handle these Requests. 

When developing modern applications we expose what are called ReSTful web services.  These Requests are a GET request that gets data, a POST request that sends data securely, a PUT request that updates data, and a DELETE request that deletes data.

As well as deciding on the Requests, we also need to decide on we will respond with a Response to Requests.

Let's create a simple GET request that says "hello world"

app.get("/sayhello", (req, res, next) => { res.writeHead(200, {'Content-Type': 'text/html'}); res.send("Hello World"); });