Skip to content

lorlabs/response-time

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 

Repository files navigation

response-time

Response time middleware for lor.

This module creates a middleware that records the response time for requests in HTTP servers. The "response time" is defined here as the elapsed time from when a request enters this middleware to when the response is written out to the client.

Install

git clone https://github.com/lorlabs/response-time

copy response_time to your lor project directory.

Usage

example:

local lor = require("lor.index")

-- import the middleware.
local reponse_time_middleware = require("app.middleware.response_time")

local app = lor()

app:use(reponse_time_middleware({
    digits = 1,
    header = 'X-Response-Time',
    suffix = true
}))

app:get("/index", function(req, res, next)
	res:send("hello world!")
end)

app:run()

params:

{
    digits = 1, -- how many floats
    header = 'X-Response-Time', -- response header name
    suffix = true  -- add "ms" suffix or not
}

About

response time middleware for lor

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages