在我想重新设计的当前 python 应用程序中,我使用 gunicorn 和 nginx。现在,当我们迁移到云时,它让我思考:我真的需要 nginx 还是任何其他网络服务器?
在我们的云架构中,我们将使用 API 网关,我们计划通过它:
api-gateway 无法实现的 web-server 是否还有其他用途?
api-gateway 也是网络服务器的另一个花哨名称吗?
在创建 Spring Boot 项目时,我在 pom.xml 中定义了属性<packaging>war</packaging>,我可以用它来创建战争,然后将战争部署到服务器中,可能是 tomcat 或 WAS。
但是我遇到了一个名为spring-boot-maven-plugin 的插件,其文档说明它的用途是打包可执行的 jar 或 war 档案并就地运行应用程序。
我的疑问是为什么我们需要这个?
如果我的打包可以告诉我要创建什么然后可以部署它运行,那么这个插件有什么用。
我正在尝试理解一个新项目,所以想确保每一行都有意义
我正在尝试在 Spring Boot 2.1.6 版本中创建嵌入式配置服务器。启动失败说:
***************************
APPLICATION FAILED TO START
***************************
Description:
Invalid config server configuration.
Action:
If you are using the git profile, you need to set a Git URI in your configuration. If you are using a native profile and have spring.cloud.config.server.bootstrap=true, you need to use a composite configuration.
Run Code Online (Sandbox Code Playgroud)
我不确定 spring 是否清楚地记录了本机配置文件是什么,而我的 bootstrap.yml 如下所示:
---
spring:
application:
name : <name>
datasource:
url: <url>
driver-class-name: oracle.jdbc.OracleDriver
username: <username>
password: <password>
hikari:
maximum-pool-size: 1
connection-timeout: 5000
cloud:
config:
server:
bootstrap: …Run Code Online (Sandbox Code Playgroud) 我正在尝试在 Flask-restplus 应用程序中设置身份验证。我想向应用程序中的所有端点添加身份验证,但不想在每个路由上编写装饰器。
我正在寻找基于 apikey 的身份验证。问题是,我无法确定如何拦截所有请求并检查标头中的身份验证令牌。
当前代码:
authorization = {
'apikey': {
'type': 'apiKey',
'in': 'header',
'name': 'x-auth'
}
}
api = Api(
title='title',
version='1.0',
description="List of API's ",
validate=True,
authorizations=authorization,
security='apikey'
)
Run Code Online (Sandbox Code Playgroud)
完成上述步骤后,当我打开 swagger 时,我可以使用授权按钮添加令牌。但是一旦令牌被传递,我就无法拦截请求并验证令牌是否正确。
目前,我能找到的所有示例都在每条路线上添加了另一个装饰器,这是我不想要的,因为它会导致糟糕的设计和重复的代码。
目前我得到的最接近的例子是:
https://www.youtube.com/watch?v=
xF30i_A6cRw&list=LLpaDwEA6bAAPZU5lz0ZRsuw&index=1,但它还在每条路线上使用装饰器。
所以问题陈述是:
如何拦截所有请求并检查标头中的正确令牌,而不在所有路由上添加装饰器
spring-boot ×2
api-gateway ×1
configserver ×1
flask ×1
gunicorn ×1
maven-plugin ×1
nginx ×1
spring ×1
token ×1