deep-entertainment / issues

Issue tracker for deep Entertainment projects
1 stars 0 forks source link

Clarify on godottpd documentation that HttpServer should be added as a node on the scene #20

Closed Dancovich closed 2 years ago

Dancovich commented 2 years ago

The godottpd documentation gives this example on how to start a server:

var server = HttpServer.new()
server.register_router("/", MyExampleRouter.new())
server.start()

However, that code by itself won't work because HttpServer is a Node and uses the _process method to listen to requests. If it's not added to the scene, _process won't run and it won't listen to requests.

Documentation should be improved to mention that fact and either suggest that the user add HttpServer on the scene tree or suggest the following code

var server = HttpServer.new()
server.register_router("/", MyExampleRouter.new())
self.add_child(server) # Assuming "self" is a script extending Node that's inserted on a scene or it's root
server.start()
dploeger commented 2 years ago

Awesome. You're right. Thanks.

Just added this.