mirror of
https://gitlab.com/msrd0/gotham-restful.git
synced 2025-05-09 16:10:42 +00:00
use openapi_type::OpenapiType for gotham_restful
This commit is contained in:
parent
eecd192458
commit
ebea39fe0d
27 changed files with 148 additions and 866 deletions
|
@ -4,7 +4,6 @@ use crate::openapi::{
|
|||
router::OpenapiRouter
|
||||
};
|
||||
use crate::{response::ResourceError, Endpoint, FromBody, IntoResponse, Resource, Response};
|
||||
|
||||
#[cfg(feature = "cors")]
|
||||
use gotham::router::route::matcher::AccessControlRequestMethodMatcher;
|
||||
use gotham::{
|
||||
|
@ -20,10 +19,12 @@ use gotham::{
|
|||
state::{FromState, State}
|
||||
};
|
||||
use mime::{Mime, APPLICATION_JSON};
|
||||
use std::panic::RefUnwindSafe;
|
||||
#[cfg(feature = "openapi")]
|
||||
use openapi_type::OpenapiType;
|
||||
use std::{any::TypeId, panic::RefUnwindSafe};
|
||||
|
||||
/// Allow us to extract an id from a path.
|
||||
#[derive(Debug, Deserialize, StateData, StaticResponseExtender)]
|
||||
#[derive(Clone, Copy, Debug, Deserialize, StateData, StaticResponseExtender)]
|
||||
#[cfg_attr(feature = "openapi", derive(OpenapiType))]
|
||||
pub struct PathExtractor<ID: RefUnwindSafe + Send + 'static> {
|
||||
pub id: ID
|
||||
|
@ -91,6 +92,11 @@ where
|
|||
{
|
||||
trace!("entering endpoint_handler");
|
||||
let placeholders = E::Placeholders::take_from(state);
|
||||
// workaround for E::Placeholders and E::Param being the same type
|
||||
// when fixed remove `Clone` requirement on endpoint
|
||||
if TypeId::of::<E::Placeholders>() == TypeId::of::<E::Params>() {
|
||||
state.put(placeholders.clone());
|
||||
}
|
||||
let params = E::Params::take_from(state);
|
||||
|
||||
let body = match E::needs_body() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue