A routeable HTTP server for Godot.
This addon for the Godot engine includes classes to start an HTTP server which can handle requests to paths using a set of routers in the way ExpressJS works.
Create a router class that extends HttpRouter. Overwrite the methods that handle the required HTTP methods required for the specific path:
extends HttpRouter
class_name MyExampleRouter
func handle_get(request, response):
response.send(200, "Hello!")
This router would respond to a GET request on its path and send back a response with a 200 status code and the body "Hello!".
Afterwards, create a new HttpServer, add the router and start the server. This needs to be called from a node in the SceneTree.
var server = HttpServer.new()
server.register_router("/", MyExampleRouter.new())
add_child(server)
server.start()
Further information can be found in the API documentation:
Please check out the deep entertainment issue repository if you find bugs or have ideas for new features.