Giter Club home page Giter Club logo

Comments (3)

JoshYuJump avatar JoshYuJump commented on May 26, 2024

FastAPI 的 docs 的高级用户指南里面有提到自定义的 status_codehttps://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.

JoshYuJump avatar JoshYuJump commented on May 26, 2024

Resource 目前都使用的 FastAPI 的简单用法,从 RESTful 角度来讲,status_code 响应得并不恰当。可以当成一个需求在后续的版本处理一下。

from bali.

JoshYuJump avatar JoshYuJump commented on May 26, 2024

Resource 目前都使用的 FastAPI 的简单用法,从 RESTful 角度来讲,status_code 响应得并不恰当。可以当成一个需求在后续的版本处理一下。

PR #165

from bali.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.