I am used to insert configuration items in apache and httpd.conf
Where are the types? The configuration is to go into a node environment, for example, I want to make sure that only GET, POST and PUT are accepted and the head and trace are not accepted.
node.js system only Technically, you can reapply the Apache HTTP server in node. Js, duplicate its behavior and its structure structure. but do you?
I believe that you node. Using JS module See Document: There is no way to read the configuration from a file. The program has been created using the server Here's an example: If you really want a configuration file, you have to make it yourself myself. I suggest creating a JSON configuration file because it directly http.createServer . You provide callback that listens to requests This callback provides a
http.IncomingMessage parameter (the first parameter) that you need.
// Load Modules var http = Required ('http'); // HTTP server var server = http.createServer (function (request, response) {// "request request" request an object request console.log ('request!') To know everything about; // method ( 'GET', 'POST', 'PUT, etc.): Console.log (' http method: '+ request.method); // url: console.log (' http url: '+ request.url); / / Header: console.log ('follow HTTP header:'); console.log (request.headers); // client address: console.log ('client address:' + request.socket.address (). Address);} ); Listen on / port 8000 servers. List 7 (8000);
JSON.parse () . Then use only your configuration object program to achieve what you want.
No comments:
Post a Comment