1- -- Very minimal HTTP server inside Love2D
1+ -- Not Very minimal HTTP server inside Love2D
22local socket = require (" socket" )
33local inspect = require (" feather.lib.inspect" )
44local json = require (" feather.lib.json" )
55local Class = require (" feather.lib.class" )
66local utf8 = require (" utf8" )
77local errorhandler = require (" feather.error_handler" )
88local get_current_dir = require (" feather.utils" ).get_current_dir
9+ local Performance = require (" feather.plugins.performance" )
10+
11+ local performance = Performance ()
912
1013local logs = {}
1114
@@ -188,7 +191,8 @@ function Feather:onerror(msg, finish)
188191 end
189192end
190193
191- function Feather :update ()
194+ --- @param dt number
195+ function Feather :update (dt )
192196 local client = self .server :accept ()
193197 if client then
194198 if # logs == 0 then
@@ -224,6 +228,11 @@ function Feather:update()
224228 self .lastDelivery = os.time ()
225229 end
226230
231+ if request .path == " /performance" then
232+ local body = json .encode (performance :getResponseBody (dt ))
233+ response = self :__buildResponse (body )
234+ end
235+
227236 client :send (response )
228237 end
229238
@@ -248,9 +257,9 @@ function Feather:log(line)
248257 table.insert (logs , line )
249258
250259 --- Find a way to avoid deleting incoming logs
251- -- if #logs > self.maxTempLogs then
252- -- table.remove(logs, 1)
253- -- end
260+ if # logs > self .maxTempLogs then
261+ table.remove (logs , 1 )
262+ end
254263end
255264
256265function Feather :print (...)
0 commit comments