ptHost class
A host configuration to be sent to the server handler
class ptHost { ptHost({List<String> pub_index_files,List<extHandler> this.extensionHandlers}) { if(pub_index_files==null) { public_index_files = new List<String>(); } else { public_index_files = pub_index_files; } hostnames = new List<String>(); public_path = ""; Request = null; allow_dir_view; } extHandler _default = new Default_Handler(); extHandler get Default => _default; /* * Set the default handler for data */ void set Default(extHandler val) { _default=val; } void SetDefaultHandlers() { if(extensionHandlers==null) { extensionHandlers= new List<extHandler>(); } this.extensionHandlers.add(new PHP_Handler()); } /* * Check to see if the hostname is in our list * Returns true if found, false otherwise */ bool IsHostname(String name) { for(int i=0; i<hostnames.length; ++i) { if(hostnames[i].compareTo(name)==0) { return true; } } return false; } /* * Name of the host to be shown on the console */ String name; /* * IP Address to bind to */ String address = "127.0.0.1"; /* * Hostnames to check against from the client */ List<String> hostnames; /* * Port to bind to */ int port = 80; /* * The path to look for when serving files */ String public_path; /* * File names to look for when serving default pages such as index.html */ List<String> public_index_files; /* * Allow the server to send out a directory view if no public_index_file is found. */ bool allow_dir_view; Map toJson() { Map ret = new Map(); ret['name']=name; ret['address']=address; ret['hostnames']=hostnames; ret['port']=port; ret['public_path']=public_path; ret['public_index_files'] = public_index_files; ret['allow_dir_view']=allow_dir_view; return ret; } /* * Override the request handler from the default * You are required to close the response. * host.Request = (HttpRequest request) { * // Your code here * * request.response.close(); * } */ RequestCallback Request; List<extHandler> extensionHandlers; }
Constructors
new ptHost({List<String> pub_index_files, List<extHandler> extensionHandlers}) #
Creates a new Object instance.
Object instances have no meaningful state, and are only useful through their identity. An Object instance is equal to itself only.
docs inherited from Object
ptHost({List<String> pub_index_files,List<extHandler> this.extensionHandlers}) { if(pub_index_files==null) { public_index_files = new List<String>(); } else { public_index_files = pub_index_files; } hostnames = new List<String>(); public_path = ""; Request = null; allow_dir_view; }
Properties
extHandler Default #
extHandler get Default => _default;
void set Default(extHandler val) { _default=val; }
List<extHandler> extensionHandlers #
List<extHandler> extensionHandlers
RequestCallback Request #
RequestCallback Request
Methods
bool IsHostname(String name) #
bool IsHostname(String name) { for(int i=0; i<hostnames.length; ++i) { if(hostnames[i].compareTo(name)==0) { return true; } } return false; }
void SetDefaultHandlers() #
void SetDefaultHandlers() { if(extensionHandlers==null) { extensionHandlers= new List<extHandler>(); } this.extensionHandlers.add(new PHP_Handler()); }