Skip to content

deep-entertainment/godottpd

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

54 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GodotTPD

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.

Basic workflow

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()

Documentation

Further information can be found in the API documentation:

Issues and feature requests

Please check out the deep entertainment issue repository if you find bugs or have ideas for new features.