KoaHub平台基于Node.js开发的Koa的rewrite and index support插件代码详情
koa-static-server
Static file serving middleware for koa with directory, rewrite and index support
koa-static-server
static file serving middleware for koa with directory, rewrite and index support
Installation
$ npm install koa-static-server
API
var koa = require('koa') var app = koa() app.use(require('koa-static')(options))
Options
rootDir
{string} directory that is to be servedrootPath
{string} optional rewrite pathlog
{boolean} request access log to consolemaxage
Browser cache max-age in milliseconds. defaults to 0hidden
Allow transfer of hidden files. defaults to falsegzip
Try to serve the gzipped version of a file automatically whengzip
is supported by a client and if the requested file with.gz
extension exists. defaults to true.
Example
See examples for code examples
// example 'web' directory // web/index.html // web/file.txt var serve = require('koa-static-server') var app = require('koa')() // root index support // GET / // returns index.html // GET /file.txt // returns file.txt app.use(serve({rootDir: 'web'})) // folder support // GET /web/ // returns /web/index.html // GET /web/file.txt // returns /web/file.txt app.use(serve({rootDir: 'web', rootPath: '/web'})) // index support // GET / // returns /file.txt app.use(serve({rootDir: 'web', index: 'file.txt'})) // rewrite support // GET /web/ // returns 404 // GET /admin // returns /admin/index.html app.use(serve({rootDir: 'web', rootPath: '/admin'})) app.listen(3000) console.log('listening on port 3000')
Support
- Issues - open new issue
- IRC -
pkoretic
on freenode
License
MIT
代码地址:http://js.koahub.com/home/feature/koa-static-server

KoaHub平台基于Node.js开发的Koa的rewrite and index support插件代码详情的更多相关文章
- KoaHub平台基于Node.js开发的Koa 连接支付宝插件代码信息详情
KoaHub平台基于Node.js开发的Koa 链接支付宝插件代码信息详情 easy-alipay alipay payment & notification APIs easy-alipay ...
- KoaHub平台基于Node.js开发的Koa的简单包装到请求库的类似接口
co-request co-request promisify wrapper for request co-request Simple wrapper to the request library ...
- KoaHub平台基于Node.js开发的Koa JWT认证插件代码信息详情
koa-jwt Koa JWT authentication middleware. koa-jwt Koa middleware that validates JSON Web Tokens and ...
- KoaHub平台基于Node.js开发的Koa的调试实用程序
debug small debugging utility debug tiny node.js debugging utility modelled after node core's debugg ...
- KoaHub平台基于Node.js开发的Koa EJS渲染插件代码信息详情
koa-ejs ejs render middleware for koa koa-ejs Koa ejs view render middleware. support all feature of ...
- KoaHub平台基于Node.js开发的Koa的连接MongoDB插件代码详情
koa-mongo MongoDB middleware for koa, support connection pool. koa-mongo koa-mongo is a mongodb midd ...
- KoaHub平台基于Node.js开发的Koa的get/set session插件代码详情
koa-session2 Middleware for Koa2 to get/set session use with custom stores such as Redis or mongodb ...
- KoaHub平台基于Node.js开发的Koa的模板系统handlebars插件代码详情
koahub-handlebars koahub-handlebars koahub handlebars templates Installation $ npm install koahub-ha ...
- KoaHub平台基于Node.js开发的Koa的skip插件代码详情
koahub-skip koahub skip middleware koahub skip Conditionally skip a middleware when a condition is m ...
随机推荐
- 我用Cocos2d-x模拟《Love Live!学院偶像祭》的Live场景(一)
同样从CSDN搬过来 博客开这么久了,就发过一篇很水的文章,一直想写点正式的东西.这次准备开工一个仿其他游戏的简单小游戏,于是开博客把开发过程记录下来.这一系列文章主要讲,我是如何从零开始使用Coco ...
- weblogic 集群部署时上传jsp不更新问题
在进行集群部署的时候,进行“源可访问性”设置的时候,要注意选择“我要使部署能够通过下列位置进行访问”: 前提是必须有共享存储:
- Cocos2d-x 多分辨率适配完全解析
从Cocos2d-x 2.0.4开始,Cocos2d-x提出了自己的多分辨率支持方案,废弃了之前的retina相关设置接口,提出了design resolution概念. 有以下相关接口: CCEGL ...
- JSP编译为Java类
JSP编译为Java类: 注意可以随便写import的内容:可以写类属性.方法.main函数.内部类:可以使用内部类: JSP: <%@ page language="java&quo ...
- WebRTC音视频引擎研究(2)--VoiceEngine音频编解码器数据结构以及参数设置
1.VoiceEngine Codec数据结构 WebRTC中,用一个结构体struct CodecInst表示特定的音频编解码器对象: struct CodecInst { int pltype; ...
- xmlns:xsi ——是指xml文件遵守xml规范,xsi全名:xml schema instance
http://blog.sina.com.cn/s/blog_4b6f8d150100nx3e.html http://blog.csdn.net/iaiti/article/details/4226 ...
- 【.net 深呼吸】细说CodeDom(10):生成异常处理语句
写完这一篇,大概可以准备过年了,就算是这系列文章的收尾吧. 异常处理语句,就是常说的try...catch语句,有时候,也会带有finally子句.要生成异常处理语句,得用到CodeTryCatchF ...
- CodeForces 460B
Little Dima and Equation Time Limit:1000MS Memory Limit:262144KB 64bit IO Format:%I64d & ...
- 不常见但很有用的chrome调试工具使用方法
前面的话 对于chrome调试工具,常用的是elements标签.console标签.sources标签和network标签.但实际上,还有一些不太常见但相当实用的方法可以提高网页调试效率.本文将 ...
- 简述jpg、gif、png-8、png-24的区别,分别使用场景
gif.jpg.png格式的图片在网站制作中的区别 Gif 格式特点: 1.透明性:gif是一种布尔透明类型,即它可以使全透明,也可是全不透明,但是它并没有半透明的(alpha透明). 2.动画:gi ...