swift-toolkit
swift-toolkit copied to clipboard
EpubServer: Don't instantiate X handlers per epub being served
Currently, for each epub being served the EpubServer object creates 2 handlers, one for the manifest and one for the ressources .
As it is right now if it serves 20 epubs, there will be 40 handlers.
Instead, the server should only have 2 (or more, depending of the needs) handlers, and they should be called with a parameter (a hash or some id - TBD) to decide which ressource they serve. The routing to the ressource would be made inside the handler() instead of being directly made in the URL.
That would also fix the following problem: when wanting to remove an Epub being served from the server, we don't have the id associated to the handlers serving it, hence we can't remove these handlers.
@camill-a Yes, indeed. The parameter should be a unique publication identifier, but I think it's the responsability of this API client to provide it (as it is now).
Is this still relevant? cc @mickael-menu @aferditamuriqi
Yes, it looks like it: https://github.com/readium/r2-streamer-swift/blob/630d8953cbad98fb229233caa9d98b2ce16474b3/r2-streamer-swift/Server/PublicationServer.swift#L140-L146
Blocked until https://github.com/readium/swift-toolkit/issues/117 is resolved