mirror of
https://github.com/ntex-rs/ntex.git
synced 2025-04-01 20:07:39 +03:00
* add public ServiceConfig::register constructor to support external configuration (#250) * fix: doctest ServiceConfig::register() error (#250) * add unit testing for ServiceConfig::register() * replace pub(crate) to pub in ServiceConfig::new() (#250) --------- Co-authored-by: RuangyotN <ruangyotn@skyller.co>
This commit is contained in:
parent
eaec50d8a2
commit
e903e65e27
1 changed files with 9 additions and 2 deletions
|
@ -68,7 +68,7 @@ pub struct ServiceConfig<Err = DefaultError> {
|
|||
}
|
||||
|
||||
impl<Err: ErrorRenderer> ServiceConfig<Err> {
|
||||
pub(crate) fn new() -> Self {
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
services: Vec::new(),
|
||||
state: Extensions::new(),
|
||||
|
@ -132,7 +132,7 @@ mod tests {
|
|||
use crate::http::{Method, StatusCode};
|
||||
use crate::util::Bytes;
|
||||
use crate::web::test::{call_service, init_service, read_body, TestRequest};
|
||||
use crate::web::{self, App, HttpRequest, HttpResponse};
|
||||
use crate::web::{self, App, DefaultError, HttpRequest, HttpResponse};
|
||||
|
||||
#[crate::rt_test]
|
||||
async fn test_configure_state() {
|
||||
|
@ -205,4 +205,11 @@ mod tests {
|
|||
let resp = call_service(&srv, req).await;
|
||||
assert_eq!(resp.status(), StatusCode::OK);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_new_service_config() {
|
||||
let cfg: ServiceConfig<DefaultError> = ServiceConfig::new();
|
||||
assert!(cfg.services.is_empty());
|
||||
assert!(cfg.external.is_empty());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue