DOCS - samheutmaker/og-router GitHub Wiki

The OG router

To use

$ npm install og-router
var Router = require(__dirname + '/node_modules/og-router');  
var route = new Router();  

// Set content type for all responses
route.setContentType('text/html');
// Set folder where HTML docs are stored
route.setPublicFolder('www');
  
// The following route will route to home.html when '/home' is requested. Note: the html file must be in the same folder
// set by route.setPublicFolder('www). In our case, this would be a folder named www
route.get('/home', 'home.html', function(){});

METHODS


.setContentType(contentType); // Set the content type of all response headers   

contentType: **the content type you would like to set in string format



.setPublicFolder(pathToFolder); // Set the base folder of where html files are stored  

pathToFolder: The path to the folder that holds your HTML documents`


.get(path, fileToRender, callback);

path: the path of the request being made
fil: a string containing the path of the HTML file to send as a response
callback:a callback to execute before the HTML file it rendered


.post(path, fileToRender, callback);   

path: the path of the request being made
fileToRender: a string containing the path of the HTML file to send as a response
callback: a callback to execute before the HTML file it rendered


.patch(path, fileToRender, callback);

path: the path of the request being made fileToRender: a string containing the path of the HTML file to send as a response
callback: a callback to execute before the HTML file it rendered


.put(path, fileToRender, callback);   
path: the path of the request being made   
fileToRender: a string containing the path of the HTML file to send as a response   
callback: a callback to execute before the HTML file it rendered   

.delete(path, fileToRender, callback);   

path: the path of the request being made
fileToRender: a string containing the path of the HTML file to send as a response
callback: a callback to execute before the HTML file it rendered