Annotation Type WebServerRegistration
-
@Retention(RUNTIME) public @interface WebServerRegistration
This annotation is required for the SimpleWebsiteInterface and the AdvancedWebsiteInterface. Please place this annotation above the function which should be registered in the web server. If some feature that provides values is disabled it will provide NULL.
-
-
Required Element Summary
Required Elements Modifier and Type Required Element Description java.lang.String[]
context
The path you want to register.
-
Optional Element Summary
Optional Elements Modifier and Type Optional Element Description boolean
acceptDelete
This is only required on the SimpleWebsiteInterface.boolean
acceptDelete_GET_VALUES
If this is enabled get values in the url will be provided.boolean
acceptGet
This is only required on the SimpleWebsiteInterface.boolean
acceptGet_GET_VALUES
If this is enabled get values in the url will be provided.boolean
acceptPatch
This is only required on the SimpleWebsiteInterface.boolean
acceptPatch_FILE
Only one data type can be enabled at once! If this is enabled files can be uploaded to the webserver.boolean
acceptPatch_JSON
Only one data type can be enabled at once! If this is enabled json can be passed to the server.boolean
acceptPatch_RAW_STRING
Only one data type can be enabled at once! If this is enabled the raw string value in the post request will be provided.boolean
acceptPatch_X_WWW_FORM_URLENCODED
Only one data type can be enabled at once! If this is enabled X_WWW_FORM_URLENCODED values in the post request will be provided.boolean
acceptPathValues
If you use the path values feature please set this to true.boolean
acceptPost
This is only required on the SimpleWebsiteInterface.boolean
acceptPost_FILE
Only one data type can be enabled at once! If this is enabled files can be uploaded to the webserver.boolean
acceptPost_JSON
Only one data type can be enabled at once! If this is enabled json can be passed to the server.boolean
acceptPost_RAW_STRING
Only one data type can be enabled at once! If this is enabled the raw string value in the post request will be provided.boolean
acceptPost_X_WWW_FORM_URLENCODED
Only one data type can be enabled at once! If this is enabled X_WWW_FORM_URLENCODED values in the post request will be provided.boolean
acceptPut
This is only required on the SimpleWebsiteInterface.boolean
acceptPut_FILE
Only one data type can be enabled at once! If this is enabled files can be uploaded to the webserver.boolean
acceptPut_JSON
Only one data type can be enabled at once! If this is enabled json can be passed to the server.boolean
acceptPut_RAW_STRING
Only one data type can be enabled at once! If this is enabled the raw string value in the post request will be provided.boolean
acceptPut_X_WWW_FORM_URLENCODED
Only one data type can be enabled at once! If this is enabled X_WWW_FORM_URLENCODED values in the post request will be provided.java.lang.String
apiDescription
An simple API description.java.lang.String[]
errorMessages
An array list of error messages with their short codes separated by a ' - '.java.lang.String
exampleRequest
An example request path.java.lang.String
exampleResponse
An example response.boolean
isAPI
If you want to generate an map for your webserver set this to true if you are registering an API.java.lang.Class<?>
jsonObject
If json should be automatically managed by the webserver set here the class of the json object.int
maxFileSizeInMb
CURRENTLY NOT IN USE! WIP! Max file size in MB if file upload is enabled in this registrations.int
usageWeight
Each call of this site will add to not whitelisted IPs the specified usage weight.SpecialWebsite
website
If you want to replace the default pages like the 404 page you can define here the page.
-
-
-
Element Detail
-
context
java.lang.String[] context
The path you want to register. You can specify values like an id with a '~' between two '/'. With an '?' after an '/' can you specify that the url CAN end here. This is multiple times possible. With a double '~~' can you define that after that point every string will be stored after an slash. Also its possible to set multiple static paths with '|'. The used static path will then be stored in the path values. --------------------------------------------------------------------- Example: /user/~ With this path would you get following values on the following calls: Call: /user Return: 404 not found error! Call: /user/123 Return: [0] = 123 Call: /user/123/123 Return: 404 not found error! --------------------------------------------------------------------- Example: /search/~/?lowToHigh|highToLow/?modifiers/~ With this path would you get following values on the following calls: Call: /search Return: 404 not found error! Call: /search/Im%20a%20Test%20Search Return: [0] = Im a Test Search Call: /search/Im%20a%20Test%20Search/lowToHigh Return: [0] = Im a Test Search [1] = lowToHigh Call: /search/Im%20a%20Test%20Search/someThingElse Return: 404 not found error! Call: /search/Im%20a%20Test%20Search/highToLow/modifiers/reverse Return: [0] = Im a Test Search [1] = highToLow [2] = reverse --------------------------------------------------------------------- Example: /settings/?category/~/?view With this path would you get following values on the following calls: Call: /settings Return: [EMPTY] Call: /settings/category/1 Return: [0] = 1 Call: /settings/category/1/view Return: [0] = 1 [1] = view --------------------------------------------------------------------- Example: /download/~~ With this path would you get following values on the following calls: Call: /download Return: 404 not found error! Call: /download/id123 Return: [0] = id123 Call: /download/id123/id456/id789 Return: [0] = id123 [1] = id456 [2] = id789 --------------------------------------------------------------------- If you want more examples look in the WebServerTest class.
- Returns:
- The path for the registration
-
-
-
acceptPost_X_WWW_FORM_URLENCODED
boolean acceptPost_X_WWW_FORM_URLENCODED
Only one data type can be enabled at once! If this is enabled X_WWW_FORM_URLENCODED values in the post request will be provided. Please be aware that any request that does not provide the "content-type" header with the value "application/x-www-form-urlencoded" will be rejected!- Returns:
- Should the post values be provided by the web server?
- Default:
- true
-
-
-
acceptPost_JSON
boolean acceptPost_JSON
Only one data type can be enabled at once! If this is enabled json can be passed to the server. Please be aware that any request that does not provide the "content-type" header with the value "application/json" will be rejected!- Returns:
- Should the web server read the body and parse it to your json object?
- Default:
- false
-
-
-
acceptPut_JSON
boolean acceptPut_JSON
Only one data type can be enabled at once! If this is enabled json can be passed to the server. Please be aware that any request that does not provide the "content-type" header with the value "application/json" will be rejected!- Returns:
- Should the web server read the body and parse it to your json object?
- Default:
- false
-
-
-
acceptPatch_JSON
boolean acceptPatch_JSON
Only one data type can be enabled at once! If this is enabled json can be passed to the server. Please be aware that any request that does not provide the "content-type" header with the value "application/json" will be rejected!- Returns:
- Should the web server read the body and parse it to your json object?
- Default:
- false
-
-
-
website
SpecialWebsite website
If you want to replace the default pages like the 404 page you can define here the page. Should you use this feature its not required for the special page to have a valid context because its ignored if this is set. Special pages cant have passed any values by the webserver except for the HttpExchange object. Can only be used on SimpleWebsiteInterface!- Returns:
- ENUM which special page should be defined!
- Default:
- me.scolastico.tools.web.enums.SpecialWebsite.NORMAL_PAGE
-
-
-
maxFileSizeInMb
int maxFileSizeInMb
CURRENTLY NOT IN USE! WIP! Max file size in MB if file upload is enabled in this registrations. Default is 256MB. On larger files its recommended to use a synchronized function because the file is until you save it in your function completely in the system ram.- Returns:
- Max file size for uploads in MB.
- Default:
- 256
-
-
-
usageWeight
int usageWeight
Each call of this site will add to not whitelisted IPs the specified usage weight. If the usage weight exceeds the configured max weight per use of the web server the user gets an 429 error and the LIMIT_REACHED_PAGE will be shown. If the weight is 0 the user can open this page even if he is at max weight. The default max weight is 60000. An user loses every second 100 weight until he is back on 0.- Returns:
- The weight for each usage.
- Default:
- 0
-
-