Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Abilities to insert or delete the handlers in RoutedHTTPHandler #77

Closed
timyeou1234 opened this issue Jan 31, 2024 · 1 comment · Fixed by #81
Closed

Abilities to insert or delete the handlers in RoutedHTTPHandler #77

timyeou1234 opened this issue Jan 31, 2024 · 1 comment · Fixed by #81

Comments

@timyeou1234
Copy link

timyeou1234 commented Jan 31, 2024

We currently only support for

public mutating func appendRoute(_ route: HTTPRoute, to handler: HTTPHandler) {
        handlers.append((route, handler))
    }
    public mutating func appendRoute(_ route: HTTPRoute,
                                     handler: @Sendable @escaping (HTTPRequest) async throws -> HTTPResponse) {
        handlers.append((route, ClosureHTTPHandler(handler)))
    }

Can we also have the function that inserts at 0 or remove all handlers.
The scenario we encounter is that we use it on the UI test, while we need to mock a response change, we will need to change the handlers array to make it happen, if append is the only function, we will need to rebuild a server again to make the change.

@swhitty swhitty linked a pull request Apr 12, 2024 that will close this issue
@swhitty
Copy link
Owner

swhitty commented Apr 12, 2024

Great suggestion @timyeou1234 🙏🏻

#81 adds insertRoute(_, at: to:) along with conformance to RangeReplaceableCollection which provides many more methods that may be useful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants