Comments (9)
默认情况下 response 确实 status_code = None;
如果你设置过 status_code, 或者有 res.render(StatusError) 则这里的 status_code 应该就不是 None 了.
from salvo.
这里要返回个默认值吗?
from salvo.
默认值就是none.没啥意义,所以大概做了个判断。
from salvo.
在 handler 返回时,res.status_code(StatusCode::CREATED) (or StatusCode::OK );,可以在中间件中获取到 status_code了。
在返回成功时,能默认给一个 res.status_code(StatusCode::OK) 吗?
from salvo.
做了一点修改, 其实现在的 None
就当作 StatusCode::OK
. 不过我仍然想明确区分用户有没有显式设置状态码. 所以, 这里的 status_code
类型是 Option<StatusCode>
.
from salvo.
嗯。我觉得这样会好点。
from salvo.
在 handler 里, res.render() 这个方法里,返回成功时,设置一下状态码,这样可行吗?
from salvo.
状态码是会设置的,只是是在所有的handler执行完毕。而log中间件也是handler 所以设置晚于这个handler的执行。
from salvo.
明白了🌹
from salvo.
Related Issues (20)
- OAPI : #[salvo(schema(name = XXX))] expects an identifier instead of a "string" literal HOT 7
- OAPI : Short FlexNamer doesn't respect schemas name HOT 3
- `oapi::ToParameters` trait requires `oapi::Extractible` trait, which is not necessary HOT 1
- Error display in `StatusError` implementation
- 使用PathParam时,路由通配符<**id>不生效 HOT 3
- Rename Affix HOT 6
- Server Logs Only Show HTTP/1.1 with `http2-cleartext` Feature in `salvo` Crate HOT 3
- Additionally, even when I disable the `http2` feature, the server still handles HTTP/2 requests. I don't think it should behave this way. HOT 10
- Sentry documentation
- OpenAPI page does not render
- Rename hoop HOT 5
- Add compression support to websockets HOT 2
- Derive `ToSchema` not work for unit enum variants
- 根据例子设置自定义页面404,发现res.status_code 一直是None HOT 1
- session 失效了
- 0.71.1: cannot call non-const fn `Identity::new` in constant functions HOT 2
- 希望增加个named函数 HOT 2
- Force HTTPS
- Provide ability to setup Content-Type for each file or type in StaticDir HOT 1
- 静态文件服务用不了。按照文档上的写。没有use salvo::serve_static::StaticDir;中的serve_static没有 HOT 1
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 salvo.