HolyLib Wiki

HttpServer

HttpServer

This class represents the HttpServer that was created using httpserver.Create

Metatable function Description
__tostring Returns a formated string of the HttpServer -> HttpServer [Address:Port]
__index Used to find the functions on the metatable and access saved variables
__newindex Used to allow one to save variables on the object

Methods

HttpServer:Delete( string path, function callback, boolean ipWhitelist = false )
Adds the given Delete path to the HttpServer.
HttpServer:Get( string path, function callback, boolean ipWhitelist = false )
Adds the given Get path to the HttpServer.
string HttpServer:GetAddress( )
Returns the address that was originally passed to HttpServer:Start
string HttpServer:GetName( )
Returns the name set by HttpServer:SetName, defaults to NONAME
number HttpServer:GetPort( )
Returns the port that was originally passed to HttpServer:Start
table HttpServer:GetTable( )
Returns the lua table used by newindex and index
boolean HttpServer:IsRunning( )
Returns true if the HTTPServer is running.
boolean HttpServer:IsValid( )
Returns whether this HttpServer is valid.
HttpServer:Options( string path, function callback, boolean ipWhitelist = false )
Adds the given Options path to the HttpServer.
HttpServer:Patch( string path, function callback, boolean ipWhitelist = false )
Adds the given Patch path to the HttpServer.
HttpServer:Post( string path, function callback, boolean ipWhitelist = false )
Adds the given Post path to the HttpServer.
HttpServer:Put( string path, function callback, boolean ipWhitelist = false )
Adds the given Put path to the HttpServer.
HttpServer:RemoveMountPoint( string mountPoint )
This removes all mounts for the given path.
HttpServer:SetKeepAliveMaxCount( number amount )
Sets the maximum amount of connections that can be kept alive at the same time.
HttpServer:SetKeepAliveTimeout( number sec )
Sets the maximum time a connection is kept alive.
HttpServer:SetMountPoint( string mountPoint, string folder )
This mounts the given folder to the given path. You can call this multiple times for the same path to mount multiple folders to it.
HttpServer:SetName( string name )
Sets the name of the HttpServer.
The length of the name is limited to 64 characters.
HttpServer:SetPayloadMaxLength( number maxLength )
Sets the maximum payload length.
HttpServer:SetReadTimeout( number sec, number usec )
Sets the maximum amount of time before a read times out.
HttpServer:SetTCPnodelay( boolean noDelay )
Sets whether a delay should be added to tcp or not.
HttpServer:SetThreadSleep( number sleepTime )
The number of ms threads sleep before checking again if a request was handled.
Useful to raise it when you let requests wait for a while.
HttpServer:SetWriteTimeout( number sec, number usec )
Sets the maximum amount of time before a write times out.
HttpServer:Start( string address, number port )
This will start or restart the HTTP Server, and it will listen on the given address + port. If a Method function like HttpServer:Get was called after this was called, you need to call this function again!
HttpServer:Stop()
This stops the HTTP Server.
HttpServer:Think()
Goes through all requests and calls their callbacks or deletes them after they were sent out. This is already internally called every frame, so you don't need to call this.