是什么让Express属于框架类别而不是Web服务器类别? [英] What makes Express fall in the category of framework instead of web server?

查看:163
本文介绍了是什么让Express属于框架类别而不是Web服务器类别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很惊讶地看到它被称为框架.在MEAN堆栈的首字母缩写词中,它替换了同时都是Web服务器的Web服务器(A)pache"和(I)IS"(例如LAMP,WISP等),这并不是说不将其称为框架,但是任何人都可以澄清为什么它会进入框架阵营吗?

I was surprised to see that it's called a framework. In the MEAN stack acronym, it replaces the web server "(A)pache" and "(I)IS" (e.g. LAMP, WISP, etc.) which are both web servers - not that that's reason to not call it a framework, but can anyone provide clarity as to why it falls into the framework camp?

推荐答案

首先, Express不是Web服务器.它没有自己的Web服务器代码. 它可以为您创建标准的node.js http服务器(当您执行app.listen()时,也可​​以创建自己的httphttps服务器,并将其作为设置的一部分传递给Express.

First off, Express isn't a web server. It does not have its own web server code. It can either create a standard node.js http server for you (when you do app.listen() or you can create your own http or https server and pass it to Express as part of the setup.

相反,它是"Web服务器之上的框架".它提供了一种通用机制,用于定义路由和中间件,错误处理程序和模板渲染器(以及其他内容).

Instead, it's a "framework on top of a web server". It provides a general purpose mechanism for defining routes and middleware, error handlers and template renderers (and other things).

为此,有大量的NPM插件通过Express中间件或Express路由机制或呈现API(它们以标准方式插入框架)插入到您的Web服务器中.我认为,通过标准机制进行插入的方法就是使其成为框架的原因.

As an indication of this, there are tons of NPM add-ons that plug-in to your web server via the Express middleware or Express routing mechanism or rendering APIs (they plug into the framework in a standard way). This means of plugging in via a standard mechanism is, in my opinion, what makes it a framework.

因此,虽然Apache实际上实际上是一个Web服务器,但是Express是在已经内置于node.js的Web服务器之上运行的层.

So, whereas Apache is actually a web server itself, Express is a layer that runs on top of the web server that is already built into node.js.

这肯定不是通用编程框架,而是非常特定类型的Web服务器框架.

It's certainly not a general purpose programming framework, but a very specific type of web server framework.

在WikiPedia的软件框架"页面上:

From WikiPedia's page for "Software framework":

在计算机编程中,软件框架是一种抽象,其中可以通过其他用户编写的代码有选择地更改提供通用功能的软件,从而提供特定于应用程序的软件.软件框架提供了构建和部署应用程序的标准方法.软件框架是一种通用的,可重用的软件环境,它在较大的软件平台中提供特定的功能,以促进软件应用程序,产品和解决方案的开发.

In computer programming, a software framework is an abstraction in which software providing generic functionality can be selectively changed by additional user-written code, thus providing application-specific software. A software framework provides a standard way to build and deploy applications. A software framework is a universal, reusable software environment that provides particular functionality as part of a larger software platform to facilitate development of software applications, products and solutions

根据此定义评估Express,它会为所有这些元素打勾:

Evaluating Express against this definition, it gets checkmarks for all these elements:

✔  Abstraction providing generic functionality
✔  can be selectively changed by additional user-written code
✔  thus providing application-specific software
✔  A software framework provides a standard way to build and deploy applications
✔  A software framework is a universal, reusable software environment that provides particular functionality as part of a larger software platform to facilitate development of software applications, products and solutions

在这种情况下,应用程序"是一个node.js Web服务器.

"applications" in this case is a node.js web server.

这篇关于是什么让Express属于框架类别而不是Web服务器类别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆