Commit 4f679277 authored by Gregor Hartmann's avatar Gregor Hartmann Committed by Marcel Stör
Browse files

Fix ftpserver documentation and some formating in httpserver.md (#3322)

parent 1503e280
...@@ -34,7 +34,7 @@ This implementation is by [Terry Ellison](https://github.com/TerryE), but I wish ...@@ -34,7 +34,7 @@ This implementation is by [Terry Ellison](https://github.com/TerryE), but I wish
Create the FTP server on the standard ports 20 and 21. The global variable `FTP` is set to the server object. Create the FTP server on the standard ports 20 and 21. The global variable `FTP` is set to the server object.
#### Syntax #### Syntax
`FTP.createServer(user, pass[, dbgFlag])` `FTP:createServer(user, pass[, dbgFlag])`
#### Parameters #### Parameters
- `user`: Username for access to the server - `user`: Username for access to the server
...@@ -46,14 +46,14 @@ Create the FTP server on the standard ports 20 and 21. The global variable `FTP ...@@ -46,14 +46,14 @@ Create the FTP server on the standard ports 20 and 21. The global variable `FTP
#### Example #### Example
```Lua ```Lua
require("ftpserver").createServer('user', 'password') require("ftpserver"):createServer('user', 'password')
``` ```
## open() ## open()
Wrapper to createServer() which also connects to the WiFi channel. Wrapper to createServer() which also connects to the WiFi channel.
#### Syntax #### Syntax
`FTP.open(user, pass, ssid, wifipwd, dbgFlag)` `FTP:open(user, pass, ssid, wifipwd, dbgFlag)`
#### Parameters #### Parameters
- `user`: Username for access to the server - `user`: Username for access to the server
...@@ -67,14 +67,14 @@ Wrapper to createServer() which also connects to the WiFi channel. ...@@ -67,14 +67,14 @@ Wrapper to createServer() which also connects to the WiFi channel.
#### Example #### Example
```Lua ```Lua
require("ftpserver").open('user', 'password', 'myWifi', 'wifiPassword') require("ftpserver"):open('user', 'password', 'myWifi', 'wifiPassword')
``` ```
## close() ## close()
Close down server including any sockets and return all resources to Lua. Note that this include removing the FTP global variable and package references. Close down server including any sockets and return all resources to Lua. Note that this include removing the FTP global variable and package references.
#### Syntax #### Syntax
`FTP.close()` `FTP:close()`
#### Parameters #### Parameters
None None
...@@ -84,5 +84,5 @@ None ...@@ -84,5 +84,5 @@ None
#### Example #### Example
```Lua ```Lua
FTP.close() FTP:close()
``` ```
...@@ -38,7 +38,6 @@ Callback function has 2 arguments: `req` (request) and `res` (response). The fir ...@@ -38,7 +38,6 @@ Callback function has 2 arguments: `req` (request) and `res` (response). The fir
- `url`: Requested URL - `url`: Requested URL
- `onheader`: assign a function to this value which will be called as soon as HTTP headers like `content-type` are available. - `onheader`: assign a function to this value which will be called as soon as HTTP headers like `content-type` are available.
This handler function has 3 parameters: This handler function has 3 parameters:
- `self`: `req` object - `self`: `req` object
- `name`: Header name. Will allways be lowercase. - `name`: Header name. Will allways be lowercase.
- `value`: Header value - `value`: Header value
...@@ -51,20 +50,18 @@ Callback function has 2 arguments: `req` (request) and `res` (response). The fir ...@@ -51,20 +50,18 @@ Callback function has 2 arguments: `req` (request) and `res` (response). The fir
The second object holds functions: The second object holds functions:
- `send(self, data, [response_code])`: Function to send data to client. - `send(self, data, [response_code])`: Function to send data to client.
- `self`: `res` object
- `self`: `res` object - `data`: data to send (may be nil)
- `data`: data to send (may be nil) - `response_code`: the HTTP response code like `200`(default) or `404` (for example) *NOTE* if there are several calls with response_code given only the first one will be used. Any further codes given will be ignored.
- `response_code`: the HTTP response code like `200`(default) or `404` (for example) *NOTE* if there are several calls with response_code given only the first one will be used. Any further codes given will be ignored.
- `send_header(self, header_name, header_data)`: Function to send HTTP headers to client. This function will not be available after data has been sent. (It will be nil.) - `send_header(self, header_name, header_data)`: Function to send HTTP headers to client. This function will not be available after data has been sent. (It will be nil.)
- `self`: `res` object
- `self`: `res` object - `header_name`: the HTTP header name
- `header_name`: the HTTP header name - `header_data`: the HTTP header data
- `header_data`: the HTTP header data
- `finish([data[, response_code]])`: Function to finalize connection, optionally sending data and return code. - `finish([data[, response_code]])`: Function to finalize connection, optionally sending data and return code.
- `data`: optional data to send on connection finalizing - `data`: optional data to send on connection finalizing
- `response_code`: the HTTP response code like `200`(default) or `404` (for example) *NOTE* if there are several calls with response_code given only the first one will be used. Any further codes given will be ignored. - `response_code`: the HTTP response code like `200`(default) or `404` (for example) *NOTE* if there are several calls with response_code given only the first one will be used. Any further codes given will be ignored.
Full example can be found in [http-example.lua](../../lua_modules/http/http-example.lua) Full example can be found in [http-example.lua](../../lua_modules/http/http-example.lua)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment