Skip to content

Protecting Swagger UI Endpoint #665

Closed Answered by NexRX
isala404 asked this question in Q&A
Discussion options

You must be logged in to vote

I'm not sure about the second one since i haven't messed about with it.

but for your first question, my approach would be to add a Middleware layer and handle requests that start or contain your docs.

example:

pub struct PathProtection;
impl<E: Endpoint> Middleware<E> for PathProtection {
    type Output = PathProtectionImpl<E>;

    fn transform(&self, ep: E) -> Self::Output {
        PathProtectionImpl { ep }
    }
}

pub struct PathProtectionImpl<E> {
    ep: E,
}
#[poem::async_trait]
impl<E: Endpoint> Endpoint for PathProtectionImpl<E> {
    type Output = E::Output;

    async fn call(&self, req: Request) -> poem::Result<Self::Output> {
        const DOC_PATH: &str = "/doc";

        if

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by isala404
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants