make the endpoints at request time #9

Merged
yagich merged 2 commits from serve-on-request into main 2022-07-04 20:04:07 +00:00
Owner

partially addresses #8.
the old server flow was:

  1. request server start
  2. make an endpoint for every file in the server directory, with a bind being the file name
  3. make an endpoint for index.html to be in root /
  4. serve request for files that endpoints were made for; for others, a generic 500 was returned.

the new flow:
1. request server start
2. make an endpoint for index.html to be in root /
3. when a request is made, the fallback function is called with a bind being the endpoint
4. open file in the server directory if it exists, if not, or if reading the file fails, return 500.

since e44cac165a, godot-http-server was synced with upstream (where relevant), the binds system was deprecated, and the flow is updated to not use the fallback function:

  1. request server start
  2. make an endpoint for "/", which would match any path, and bind it to the _serve_file() function
  3. open file in the server directory if it exists. if not, or if reading the file fails, return 500.
    1. additionally, if the endpoint is /, replace the file path with index.html.

this also gave me an idea: in the future, it would be cool to specify custom error pages

~~partially~~ addresses #8. the old server flow was: 1. request server start 2. make an endpoint for every file in the server directory, with a bind being the file name 3. make an endpoint for `index.html` to be in root `/` 4. serve request for files that endpoints were made for; for others, a generic 500 was returned. ~~the new flow:~~ ~~1. request server start~~ ~~2. make an endpoint for `index.html` to be in root `/`~~ ~~3. when a request is made, the fallback function is called with a bind being the endpoint~~ ~~4. open file in the server directory if it exists, if not, or if reading the file fails, return 500.~~ since e44cac165a, [godot-http-server](https://https://github.com/velopman/godot-http-server/) was synced with upstream (where relevant), the binds system was deprecated, and the flow is updated to not use the fallback function: 1. request server start 2. make an endpoint for "/", which would match any path, and bind it to the `_serve_file()` function 3. open file in the server directory if it exists. if not, or if reading the file fails, return 500. 1. additionally, if the endpoint is `/`, replace the file path with `index.html`. this also gave me an idea: in the future, it would be cool to specify custom error pages
yagich added the
enhancement
label 2022-07-03 20:46:44 +00:00
yagich added 1 commit 2022-07-03 20:46:45 +00:00
yagich added 1 commit 2022-07-04 03:44:06 +00:00
yagich merged commit 47dc68028c into main 2022-07-04 20:04:07 +00:00
Sign in to join this conversation.
No reviewers
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: yagich/tickle-godot-frontend#9
No description provided.