0.5.5 • Published 5 years ago

httpcontroller v0.5.5

Weekly downloads
2
License
ISC
Repository
github
Last release
5 years ago

Http Controller

A Node.js module to run http server based on view/controllers.

Installation

npm install httpcontroller --save

Simplest Usage

const httpcontroller = require('httpcontroller');

const server = new httpcontroller.HttpServer("<html><body><h1>Hello World!</h1></body></html>");
server.start();
To test this code open the browser at http://localhost/

Static Site

const httpcontroller = require('httpcontroller');

const server = new httpcontroller.HttpServer(httpcontroller.StaticHandler); 
//or const server = new httpcontroller.HttpServer( { "default":httpcontroller.StaticHandler }); //the default controller to use for all requests not handled by other controllers
server.start();
Put your site content in a sub-directory called "site". Eg.: "site/index.html" (by default index.html can be accessed without declaring the file in the url).
To test this code open the browser at http://localhost/

Controllers

const httpcontroller = require('httpcontroller');

class Api extends httpcontroller.Controller {
    /* http://localhost/Api/SomeData  */
    SomeDataGET() { 
        this.JsonResponse({ data: "some data"});
    }

    /* http://localhost/Api/AnotherData */
    AnotherDataGET(){
        this.JsonResponse({ data: "some other data"});
    }
}

const server = new httpcontroller.HttpServer({ Api });
server.start();
0.5.5

5 years ago

0.5.4

5 years ago

0.5.3

5 years ago

0.5.2

5 years ago

0.5.1

5 years ago

0.5.0

5 years ago

0.4.20

5 years ago

0.4.19

5 years ago

0.4.18

5 years ago

0.4.17

5 years ago

0.4.16

5 years ago

0.4.15

5 years ago

0.4.14

5 years ago

0.4.13

5 years ago

0.4.12

5 years ago

0.4.10

5 years ago

0.4.9

5 years ago

0.4.8

5 years ago

0.4.7

5 years ago

0.4.6

5 years ago

0.4.5

5 years ago

0.4.4

5 years ago

0.4.3

5 years ago

0.4.2

5 years ago

0.4.1

5 years ago

0.4.0

5 years ago

0.3.1

5 years ago

0.3.0

5 years ago

0.2.10

5 years ago

0.2.9

5 years ago

0.2.8

5 years ago

0.2.7

5 years ago

0.2.6

5 years ago

0.2.5

5 years ago

0.2.4

5 years ago

0.2.3

5 years ago

0.2.2

5 years ago

0.2.1

5 years ago

0.2.0

5 years ago

0.1.7

5 years ago

0.1.6

5 years ago

0.1.5

5 years ago

0.1.4

5 years ago

0.1.3

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago