hserver
this is a web app framework
Install
npm install hserver --save
Example
-
Hello World
'use strict';const Server = ;const port = 80;var app = ;app;app;app;console; -
A simple file server
'use strict';const Server = ;const path = ;const fs = ;const mime = ;const port = 8080;var app = ;app;app; -
hserver-static middleware(hserver-static)
npm install hserver-static --save
'use strict';const Hserver = ;const Hstatic = ;const port = 8081;const app = ;// static middlewareapp;app;console;
API
app.use()
accept a function as argument,It is used as a middleware for loading, and argunment function bind context as inner this. the function's argunmet next can load next middleware.
context.app
-the server applicationcontext.request
-the packaging of the requestcontext.response
-the packaging of the responsecontext.req
-the node origin requestcontext.res
-the node origin responsecontext.url
-the request urlcontext.method
-the request methodcontext.accept
-the request acceptcontext.status
-the response statuscontext.body
-the response bodycontext.headerSent
-the response headerSentcontext.writable
-the request writablecontext.get
-get request headercontext.set
-set request header
app.listen()
can start a node origin http server.
app.callback()
a request handle function,you can use it at origin http server,such as
const http = ;const server = http;server;