Comments (3)
在 FastAPI
的 docs 的高级用户指南里面有提到自定义的 status_code
,https://fastapi.tiangolo.com/advanced/additional-status-codes/。Bali 的 Resource 目前并没有支持这个特性。
正如你所说,如果需要更细粒度的 status_code
,Bali 的 Resource 是可以变成 FastAPI 的 Router 的,然后使用 FastAPI 的方式。Override HTTP Actions
# Get the origin router
router = GreeterResource.as_router()
# Override the actions using the FastAPI normal way
@router.get("/")
def root():
return {"message": "Hello World"}
而且似乎Resource是无法使用fastapi中的Depends这个十分方便的特性
Depends
这个特性我个人还在调研,很多其他语言很早就有依赖注入,Python 的框架里面 nameko 也有类似的。
Resource/ModelResource怎样和APIRoute配合形成类似flask和sanic中blueprint的效果?
Flask/Sanic 的 Blueprint
和 FastAPI 的 mount,看起来都是当单体项目变成复杂后需要模块的时候产生的需求。而 Bali 定位的是云原生的微服务场景,模块可能不会复杂到需要引入 blueprint
,供你参考。
from bali.
Resource
目前都使用的 FastAPI 的简单用法,从 RESTful 角度来讲,status_code 响应得并不恰当。可以当成一个需求在后续的版本处理一下。
from bali.
Resource
目前都使用的 FastAPI 的简单用法,从 RESTful 角度来讲,status_code 响应得并不恰当。可以当成一个需求在后续的版本处理一下。
PR #165
from bali.
Related Issues (20)
- Introduce the protobuf practice which `bali` using HOT 1
- Enhanced configuration HOT 1
- logging out of the box
- Unify the file structure of different types of services HOT 1
- Docs of why to use bali framework
- 打开openapi页面时有的sqlalchemy转换报错 HOT 11
- Integrate FastAPI migration, like `Flask-Migrate`
- asyncio SQLAlchemy HOT 2
- Hope to support python11 version HOT 1
- 是否可以加个微信群或者其他沟通渠道 HOT 17
- error when using alembic with asyncpg HOT 1
- Feature: `Bali.register()` - support separate registration of `HTTP Router` and `RPC Service` HOT 2
- How to modify the default port? HOT 2
- fetaure: allows customization of the settings module. HOT 1
- 希望完善一下tour和examples
- 能否把 click, pydantic-sqlalchemy, pytz 的依赖升级一下
- Complete documentation
- Distributed transactions solution or integrate with third-party methods HOT 1
- install failed HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bali.