Skip to content

EnpointHandler checkPath logic is broken #136

@andr3h3nriqu3s11

Description

@andr3h3nriqu3s11

Currently, if you create an endpoint handler and set checkPath to false the endpoint code will never be called.

        var fooHandler = zap.Middleware.EndpointHandler(Handler, Context).init(
            fooEndpoint.endpoint(),
            null,
            .{
                .checkPath = false,
            },
        );

This seems to be caused by the logic in EndpointHandler.onRequest.
As self.endpoint.onRequest(r) is only called inside this if, and if checkPath is false it will always skip endpoint, instead of always running the enpoint.

            if (self.options.checkPath and
                std.mem.startsWith(u8, r.path orelse "", self.endpoint.settings.path))
            {
                self.endpoint.onRequest(r);
            }

Reverting 9a80747 should fix the issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions