Readme.md translated
This commit is contained in:
parent
cca9fb8052
commit
48ff042e0e
1 changed files with 54 additions and 54 deletions
108
README.md
108
README.md
|
@ -2,77 +2,77 @@
|
||||||
|
|
||||||
LiHaSo Webserver Modul
|
LiHaSo Webserver Modul
|
||||||
|
|
||||||
## Öffentliche Funktionen:
|
## Public functions:
|
||||||
|
|
||||||
### Konfiguration des Server Moduls:
|
### Server module configuration:
|
||||||
|
|
||||||
Mögliche Parameter:
|
Parameter List:
|
||||||
```
|
```
|
||||||
lweb::#conf_port ;Hörender Port, z.B. "80"
|
lweb::#conf_port ;Listening Port
|
||||||
lweb::#conf_binding ;Interface Binding z.B. nur Lokalhost mit "127.0.0.1"
|
lweb::#conf_binding ;Interface binding e.g. only localhost with "127.0.0.1"
|
||||||
lweb::#conf_defaultfile ;Standard wenn keine Datei (Extension angegeben ist) z.B. "index.php"
|
lweb::#conf_defaultfile ;Default file wen no file is selected(With extension!) e.g. "index.php"
|
||||||
lweb::#conf_basedir ;Standard Verzeichnis z.B. "/srv/www/htdocs/"
|
lweb::#conf_basedir ;Default directory e.g. "/srv/www/htdocs/"
|
||||||
lweb::#conf_error400 ;TODO:error400 bearbeitung
|
lweb::#conf_error400 ;TBD:error400
|
||||||
lweb::#conf_max_clients ;Maximale Clientconnections (Memory beachten)
|
lweb::#conf_max_clients ;Max clients connected at the same time. (Watch memory limits!)
|
||||||
lweb::#conf_server_type ;Derzeit ohne Funktion (Später z.B. HTTPS und HTTP oder HTTP/2 usw.)
|
lweb::#conf_server_type ;Currently no function.(e.g. HTTPS, HTTP/2)
|
||||||
lweb::#conf_cache_enable ;Bei wert auf 1 Setzen um zu Aktivieren diese Funktion ist aber derzeit mit Vorsicht zu geniessen!!!!
|
lweb::#conf_cache_enable ;It enable the cache mode (0 disabled and 1 enabled.) Currently with debugger unstable.
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Funktionen
|
#### Functions
|
||||||
`lweb::set_config(parameter.i=#conf_defaultfile, setting.s="index.html")`
|
`lweb::set_config(parameter.i=#conf_defaultfile, setting.s="index.html")`
|
||||||
|
|
||||||
Dass setting ist immer ein String.
|
Setting must be a string.
|
||||||
|
|
||||||
Rückgabewert ist `#True` oder `#False.`
|
Response is `#True` or `#False.`
|
||||||
|
|
||||||
|
|
||||||
`lweb::get_config(parameter.i=#conf_defaultfile)`
|
`lweb::get_config(parameter.i=#conf_defaultfile)`
|
||||||
|
|
||||||
Der Rückgabewert ist immer einen String.
|
Responste is everytime a string.
|
||||||
|
|
||||||
### Starten des Servers
|
### Server start
|
||||||
`lweb::start_server()`
|
`lweb::start_server()`
|
||||||
|
|
||||||
Rückgabewert ist `#True` oder `#False.`
|
Response is `#True` or `#False.`
|
||||||
|
|
||||||
### Verschiedene arten des Handlers Registrieren & Proceduren:
|
### Different way to register a handler:
|
||||||
|
|
||||||
`lweb::register_client_handler(Route.s, Callback.i, AppPrototype.i = #handler_proto_get, RouteType.i = #handler_sub)`
|
`lweb::register_client_handler(Route.s, Callback.i, AppPrototype.i = #handler_proto_get, RouteType.i = #handler_sub)`
|
||||||
|
|
||||||
Rückgabewerte ist immer ein JSONString!
|
Response is a JSONString!
|
||||||
|
|
||||||
AppPrototype Möglichkeiten:
|
AppPrototype parameter:
|
||||||
```
|
```
|
||||||
lweb::#handler_proto_universal ;Für HTTP POST und GET Requests Nimmt Optional einen String entgegen.
|
lweb::#handler_proto_universal ;Works with HTTP POST and GET requests and takes optional a string.
|
||||||
lweb::#handler_proto_post ;Nur für HTTP POST Requests Nimmt Zwingend einen String entgegen.
|
lweb::#handler_proto_post ;Works only with HTTP POST and needs a string.
|
||||||
lweb::#handler_proto_get ;Nur für HTTP GET Requests Nimmt keinen String entgegen.
|
lweb::#handler_proto_get ;Works only with HTTP GET withouth a string.
|
||||||
```
|
```
|
||||||
|
|
||||||
RouteType Möglichkeiten:
|
RouteType parameter:
|
||||||
```
|
```
|
||||||
lweb::#handler_only ;Reagiert nur auf die Url (Bsp. /rest/v1/test aber nicht auf /rest/v1/test/sub)
|
lweb::#handler_only ;React only on a explicit Url (e.g. /rest/v1/test but not /rest/v1/test/sub)
|
||||||
lweb::#handler_sub ;Reagiert auf eine ganze Url die begint. (Bsp. /rest/v1/test sowie auch auf /rest/v1/test/sub)
|
lweb::#handler_sub ;React on a full sub url. (e.g. /rest/v1/test and also /rest/v1/test/sub)
|
||||||
lweb::#handler_type ;Reagiert auf datentypen (zb. *.php = "php")
|
lweb::#handler_type ;React on called file type (e.g. *.php = "php")
|
||||||
```
|
```
|
||||||
|
|
||||||
Map für Antwort ist eine einfache Stringmap:
|
Response is a simple Stringmap:
|
||||||
`NewMap Response.s()`
|
`NewMap Response.s()`
|
||||||
|
|
||||||
Wobei folgende werte entsprechend gesetzt werden müssen:
|
Following values must be set in a stringmap:
|
||||||
* `lweb::#cha_R_ResponseType = "ResponseType"` ;Element ResponseType,Mimetype mit `lweb::mimetype("html")` z.B. Setzen.
|
* `lweb::#cha_R_ResponseType = "ResponseType"` ;Element ResponseType,Mimetype set e.g. `lweb::mimetype("html")`.
|
||||||
* `lweb::#cha_R_ResponseContentType = "ResponseContentType"` ;Element ResponseContentType, `lweb::#response_string` oder `lweb::#response_Memory`
|
* `lweb::#cha_R_ResponseContentType = "ResponseContentType"` ;Element ResponseContentType, `lweb::#response_string` or `lweb::#response_Memory`
|
||||||
* `lweb::#cha_R_MemoryAdress = "MemoryAdress"` ;Element MemoryAdress, Konvertieren zu String `Str(Adresse)` wird mit `Val()` zurückkonvertiert. Und nach dem Bearbeiten wieder freigegeben!
|
* `lweb::#cha_R_MemoryAdress = "MemoryAdress"` ;Element MemoryAdress, convert to string `Str(Adresse)` converted back by `Val()`. After finished the work it will be freed!
|
||||||
* `lweb::#cha_R_MemorySize = "MemorySize"` ;Element MemorySize, Konvertieren zu String `Str(Grösse)` wird mit `Val()` zurückkonvertiert.
|
* `lweb::#cha_R_MemorySize = "MemorySize"` ;Element MemorySize, convert to string `Str(Size)` converted back by `Val()`.
|
||||||
* `lweb::#cha_R_StringBase64 = "StringBase64"` ;Element StringBase64, Base64 Encoded String
|
* `lweb::#cha_R_StringBase64 = "StringBase64"` ;Element StringBase64, Base64 encoded string
|
||||||
* `lweb::#cha_R_http_head_status = "HeaderStatus"` ;`"200 OK"`, `"300 Error"`, `"500 Server Error"` usw.
|
* `lweb::#cha_R_http_head_status = "HeaderStatus"` ;`"200 OK"`, `"300 Error"`, `"500 Server Error"` etc.
|
||||||
|
|
||||||
Zu beachten ist das entweder ein Base64 encodierter String oder ein MemoryBlock zurückgegeben werden muss!
|
It's only allowed to response a base64 encoded string or a memoryblock.
|
||||||
|
|
||||||
Komplettes Beispiel:
|
Complete example:
|
||||||
```
|
```
|
||||||
Procedure.s Sample_Header(Map Header.s())
|
Procedure.s Sample_Header(Map Header.s())
|
||||||
Define *Text
|
Define *Text
|
||||||
Define.s Encoded, ZumSenden, TBD
|
Define.s Encoded, ToSend, TBD
|
||||||
NewMap Response.s()
|
NewMap Response.s()
|
||||||
TBD="<div><div><h1>Header</h1></div><br/>"+#CRLF$
|
TBD="<div><div><h1>Header</h1></div><br/>"+#CRLF$
|
||||||
ResetMap(Header())
|
ResetMap(Header())
|
||||||
|
@ -87,50 +87,50 @@ Procedure.s Sample_Header(Map Header.s())
|
||||||
Response(lhs_web::#cha_R_StringBase64) = Encoded
|
Response(lhs_web::#cha_R_StringBase64) = Encoded
|
||||||
Response(lhs_web::#cha_R_ResponseType) = lhs_web::mimetype("html")
|
Response(lhs_web::#cha_R_ResponseType) = lhs_web::mimetype("html")
|
||||||
Response(lhs_web::#cha_R_http_head_status) = "200 OK"
|
Response(lhs_web::#cha_R_http_head_status) = "200 OK"
|
||||||
ZumSenden = lhs_web::MapToJSONString(Response())
|
ToSend = lhs_web::MapToJSONString(Response())
|
||||||
Debug "ZumSenden: " + ZumSenden
|
Debug "ToSend: " + ToSend
|
||||||
ProcedureReturn ZumSenden
|
ProcedureReturn ToSend
|
||||||
EndProcedure
|
EndProcedure
|
||||||
|
|
||||||
lhs_web::register_client_handler("/server/show_client_headers", @Sample_Header(),lhs_web::#handler_proto_get, lhs_web::#handler_sub)
|
lhs_web::register_client_handler("/server/show_client_headers", @Sample_Header(),lhs_web::#handler_proto_get, lhs_web::#handler_sub)
|
||||||
```
|
```
|
||||||
|
|
||||||
### Einen Mimetype eines Fileextensions:
|
### HTML mimetype of a file extension:
|
||||||
`lweb::mimetype(file.s)`
|
`lweb::mimetype(file.s)`
|
||||||
|
|
||||||
Gibt einen String zurück.
|
Response is a string.
|
||||||
|
|
||||||
Konvertiert z.B. `lweb::mimetype("html")` zu `"text/html"`
|
Converts e.g. `lweb::mimetype("html")` to `"text/html"`
|
||||||
|
|
||||||
### Eine Map in einen JSONString Konvertieren (z.B. in Interaktion mit einer Spiderbasic App)
|
### Convert a map to a JSONString. Interaction for example with a SpiderBasic app.
|
||||||
`lweb::MapToJSONString(Map ConvertMap.s())`
|
`lweb::MapToJSONString(Map ConvertMap.s())`
|
||||||
|
|
||||||
Gibt einen String zurück.
|
Response is a string.
|
||||||
|
|
||||||
Beispiel:
|
Example:
|
||||||
```
|
```
|
||||||
Response(lhs_web::#cha_R_ResponseContentType) = lhs_web::#response_string
|
Response(lhs_web::#cha_R_ResponseContentType) = lhs_web::#response_string
|
||||||
Response(lhs_web::#cha_R_StringBase64) = Encoded
|
Response(lhs_web::#cha_R_StringBase64) = Encoded
|
||||||
Response(lhs_web::#cha_R_ResponseType) = lhs_web::mimetype("html")
|
Response(lhs_web::#cha_R_ResponseType) = lhs_web::mimetype("html")
|
||||||
Response(lhs_web::#cha_R_http_head_status) = "200 OK"
|
Response(lhs_web::#cha_R_http_head_status) = "200 OK"
|
||||||
ZumSenden = lhs_web::MapToJSONString(Response())
|
ToSend = lhs_web::MapToJSONString(Response())
|
||||||
```
|
```
|
||||||
|
|
||||||
Ergib anschliessend einen String der wieder Zurückkonvertiert werden kann von der Hauptbearbeitungsprozedur (Client Thread in lweb.pbi).
|
The converted map would be possible to converted back by the main worker procedure (Client thread from lweb.pbi).
|
||||||
|
|
||||||
### Verifizierung ob es eine Gültige IP Adresse ist (IPv6 und IPv4)
|
### Verification if it is a valid IP Address (IPv6 and IPv4)
|
||||||
`lweb::IsIPStringValid(Adress.s)`
|
`lweb::IsIPStringValid(Adress.s)`
|
||||||
|
|
||||||
Beispiel:
|
Example:
|
||||||
```
|
```
|
||||||
setting = "192.168.256.12"
|
setting = "192.168.256.12"
|
||||||
If lweb::IsIPStringValid(setting)
|
If lweb::IsIPStringValid(setting)
|
||||||
conf_binding = setting
|
conf_binding = setting
|
||||||
Else
|
Else
|
||||||
; Fehler
|
; failed
|
||||||
conf_binding = "127.0.0.1"
|
conf_binding = "127.0.0.1"
|
||||||
EndIf
|
EndIf
|
||||||
```
|
```
|
||||||
ergibt einen Fehler und wird die Standard IP Setzen.
|
Validation will be failed because `256` is not valid.
|
||||||
|
|
||||||
Rückgabewert ist `#True` oder `#False.`
|
Response is `#True` or `#False.`
|
||||||
|
|
Loading…
Reference in a new issue