Version : 1.06
This library is use to create a basic controller class for MinimaList API Server v2.03+ template.
Library:
https://github.com/pyhoon/MinimaListController-B4J
Generated code:
Tutorial:
Release Logs
This project has been tested many many times. Please report bugs if you found any
Post your question in a new thread.
Note: This library was created on 23/09/2023 (more than 7 months) as an attachment for Web API Server (v2.04+) template. This new thread is to make the dependencies more organized and for future updates.
This library is use to create a basic controller class for MinimaList API Server v2.03+ template.
Library:
- MinimaListController.jar
- MinimaListController.xml
https://github.com/pyhoon/MinimaListController-B4J
Generated code:
SampleController:
' MinimaList Controller
' Version 1.06
Sub Class_Globals
Private Request As ServletRequest
Private Response As ServletResponse
Private HRM As HttpResponseMessage
Private Method As String
Private Version As String
Private Elements() As String
Private ApiVersionIndex As Int
Private ControllerIndex As Int
Private ElementLastIndex As Int
'Private FirstIndex As Int
'Private FirstElement As String
End Sub
Public Sub Initialize (req As ServletRequest, resp As ServletResponse)
Request = req
Response = resp
HRM.Initialize
End Sub
Private Sub ReturnBadRequest 'ignore
WebApiUtils.ReturnBadRequest(Response)
End Sub
Private Sub ReturnApiResponse 'ignore
WebApiUtils.ReturnHttpResponse(HRM, Response)
End Sub
Private Sub ReturnMethodNotAllow 'ignore
WebApiUtils.ReturnMethodNotAllow(Response)
End Sub
Private Sub ReturnErrorUnprocessableEntity 'ignore
WebApiUtils.ReturnErrorUnprocessableEntity(Response)
End Sub
' API Router
Public Sub RouteApi
Method = Request.Method.ToUpperCase
Elements = WebApiUtils.GetUriElements(Request.RequestURI)
ElementLastIndex = Elements.Length - 1
ApiVersionIndex = Main.Element.ApiVersionIndex
Version = Elements(ApiVersionIndex)
ControllerIndex = Main.Element.ApiControllerIndex
'If ElementLastIndex > ControllerIndex Then
' FirstIndex = ControllerIndex + 1
' FirstElement = Elements(FirstIndex)
'End If
Select Method
Case "GET"
'RouteGet
Case "POST"
'RoutePost
Case "PUT"
'RoutePut
Case "DELETE"
'RouteDelete
Case Else
Log("Unsupported method: " & Method)
ReturnMethodNotAllow
End Select
End Sub
Tutorial:
[Web] Tutorial - Using MinimaList Controller and Code Snippets
Introduction This tutorial is based on MinimaList API Server (version 2.05) on how to use MinimaList Controller library. For this tutorial, we will cover on using this library for creating API controller. Update: This tutorial is updated for library version 1.05. How to install Download...
www.b4x.com
Release Logs
- Version 1.06
- (add) ReturnBadRequest sub
- (add) ReturnMethodNotAllow sub
- (add) ReturnErrorUnprocessableEntity sub
This project has been tested many many times. Please report bugs if you found any
Post your question in a new thread.
Attachments
Last edited: