Created
February 21, 2018 10:36
-
-
Save chathurangat/9adfda03d5c0f0ee4cf90400ec83fc32 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {RequestHandlerService} from "./service/RequestHandlerService"; | |
const express = require('express'); | |
const router = express.Router(); | |
router.all('/*', function (request, response, next) { | |
console.log(" this will be applied to all routes "); | |
next(); | |
}); | |
router.get("/", async (request, response)=> { | |
let message = await RequestHandlerService.handleHttpRequest(request.method, request.path); | |
response.status(200).json({ | |
"message": message | |
}); | |
}); | |
router.get("/products", (request, response)=> { | |
response.status(200).json({ | |
"message": "HTTP " + request.method + " Request with URL Pattern " + request.path | |
}); | |
}); | |
router.get("/products/:id", (request, response)=> { | |
response.status(200).json({ | |
"message": "HTTP " + request.method + " Request with URL Pattern " + request.path | |
}); | |
}); | |
router.post("/products", (request, response)=> { | |
response.status(200).json({ | |
"message": "HTTP " + request.method + " Request with URL Pattern " + request.path | |
}); | |
}); | |
module.exports = router; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment