npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

rapid-httpserver

v0.1.3

Published

httpserver plugin of rapid

Downloads

15

Readme

rapid-httpserver

NPM version Dependency Status

Rapid-httpserver是由RapidJS提供的基础插件用来提供Http Server的服务能力

##Depends rapid-core : rapid 运行时支撑;

##概念 ###Extension 用来实现http的功能包装,如session, cookie, fileupload, form等,每个extension使用固定的一个接口型式,接收request与response,并返回一个处理包装对像。一般来说,extension的不包含业务功能只是扩展http行为能力的一种包装,所以使用方式相对简单没有复杂配置,所有配置接写在http.conf对像下即可,无独立配置.

###Filter 每个filter可作用于每个http访问的请求过程中,用来处理一些通用业务,如安全认证的过滤,日志打印,统计等任务,多个Filter采用链式调用,全部通过则执行最终的action,在执行过程中可以中断执行(如认证检查失失败等)。

###Action 每组Filter的未端使用一个Action,用来实现最终的业务功能。

##LifeCircle ###启动

  1. httpserver在被require时,将自动向rapid.plugin进行注册.
  2. httpserver在被require时,将进行rapid.config.watch("rapid-server"),用于发现自动配置的存在.
  3. 如果找到配置,根据autoStart=true的配置进行自动调用httpserver.start(),否则放弃启动.并等待手动执行httpserver.start(conf)方法.
  4. 当autoStart=false或未提供配置信息时,可利用httpserver.start(conf)启动server. (如果存在配置,这里将提供一个替换默认配置的机会,两次配置不会进行合并,而是完全进行覆盖).

###运行

  1. server启动后,直接监听配置端口(默认为8080),并开始接收请求.
  2. 在请求到达时,将根据配置依次通过fiterChain与actionChain两条执行链,每个请求根据配置的url会完整经过所有配置的filter链并到达action链,在actionChain的执行中,在任意配置的action被执行时,将停止继续执行下一个.如果所有都不配置,则执行defaultAction,默认返回404错误给客户端.
  3. 在处理请求的过程中,如果根据配置,需要处理请求的action或filter尚未载入(这种情况多发生在启动过程中,或受业务影响需要延迟提供的action与filter情况下.),系统将停止继续处理本次请求,并返回400或500错误.如果下次同样请求到来时,缺失的action与filter存在,则会正常派发处理.

Request流程

每个请求到达时,将根据配置依次通过fiterChain与actionChain两条执行链,每个请求根据配置(路由)的URL完整的经过fiterChain中配置的所有filter并到达actionChain,在actionChain的执行中,在任意配置的action被执行时,将停止继续执行下一个。如果所有都不配置,则执行defaultAction,默认返回404错误给客户端。

使用手册