Closed ArsenicBismuth closed 1 year ago
I'm not sure what you're asking. You what to handle a certain path/route yourself?
as it says in the readme, servez is not really meant as a library. Rather just use express
yourself and you can just copy the code in servez-lib
as a starting point.
If you want to handle a certain path yourself you add a function for that path either for a specific HTTP verb (get/put/etc)
https://expressjs.com/en/starter/basic-routing.html
Or for all requests
https://expressjs.com/en/guide/writing-middleware.html
Just register yours before app.use(express.static(root, staticOptions))
(or after if it needs to come after)
Yeah that's what I meant, thanks! I was just wondering if there's some modular way to do it, but yeah directly modifying the servez-lib
will be simpler.
So, I'm wondering if there's a way to make Servez handle HTTP request?
I know the base library uses
express
at its core, so I'm wondering if there's a feature to handle certain request programmatically instead of providing a file.The easiest (and crude) way would be to modify the
servez-lib
itself so it can handle certain pattern as a HTTP request. But I saw astaticOptions
about calling a middleware if there's no file, and wondering if I can use it as an entry point.