Updated to new Deno http server, added static file router, fixed router params, added template engines #11
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I updated the entire library to use the modern Deno http server version 0.147.0. This did involve changing the project to the fetch Request and Response under the hood, this didn't change the usage at all.
I also added a static file router, you use it via
app.static("/public", "./publicdirectory")
, then all files under./publicdirectory
are accessible through their url (ie. to access./publicdirectory/style.css
you go to http://localhost:8000/public/style.css)The other change was fixing your router params system, they weren't working as expected for me (path matching worked, route parameters didn't). I switched it over to Path-to-RegExp for simpler and more familiar usage.
In the second commit, I added template engine support. It is very similar in user syntax to express, usage is as follows:
Template engines should follow this interface, an example is included:
The other minor changes I made were:
Context#json
function now adds thecontent-type: application/json
header automaticallyContext#file
function that sends a file to the client