Skip to content

reduce the number of arguments in the Dispatcher interface (struct) funtion pointers #47

@oduortoni

Description

@oduortoni

We are passing so many arguments to each function pointer yet we can just pass struct Router that contains everything we need.

Simplifies to:

struct Dispatcher {
        HandlerFunc (*match)(struct Router* router, Request* req);
        void (*add_route)(struct Router* router, const char* pattern, HandlerFunc handler);
        void (*mount)(struct Router* parent, const char* prefix, struct Router* child);
        void (*free)(struct Dispatcher* self);
};

Once again, eliminating opaque pointers while still staying flexible enough.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions