Code Monkey home page Code Monkey logo

web-api-server-b4j's Introduction

Web API Server

Version: 2.08

Create Web API Server using B4X project template

Preview

Web API Template

If you don't want to connect to any SQL database, see MinimaList API Server

For older version webapi-b4j, please check https://github.com/pyhoon/webapi-b4j


Template:

  • Web API Server (2.08).b4xtemplate

Depends on:

Features:

  • ApiHandler and WebHandler are used for routing to Controller classes
  • HelpHandler (optional)
  • API documentation is generated automatically. You don't need external tools (e.g Postman or Swagger) for testing.
  • Access tokens can be embeded into request header in HelpHandler.
  • Controller classes are added to a list in Main module to show in the documentation.
  • Configuration
    • Web and API paths
    • Versioning
    • Simple JSON Response (Map or List)
    • Session
    • Cookies
    • Welcome message
  • Endpoint
    • Endpoint name is based on controller's name by default e.g ProductsController produces /web/api/v2/products
    • Endpoint name can be overridden by using #Name tag e.g /web/api/v2/product
    • Custom version name using #Version tag e.g v2, live, demo, dev, staging
    • Description in documentation is set using #Desc tag (in Web API v1, it was set by #Desc1, #Desc2 or Literals that was very confusing)
    • API endpoint can be hidden using #Hide tag
  • Clients

Code Example

Private Sub GetCategory (id As Long)
    ' #Version = v2
    ' #Desc = Read one Category by id
    ' #Elements = [":id"]

    DB.Table = "tbl_category"
    DB.Find(id)
    If DB.Found Then
        HRM.ResponseCode = 200
        HRM.ResponseObject = DB.First
    Else
        HRM.ResponseCode = 404
        HRM.ResponseError = "Category not found"
    End If
    DB.Close
    ReturnApiResponse
End Sub

Support this project

web-api-server-b4j's People

Contributors

pyhoon avatar

Stargazers

 avatar  avatar  avatar Mashy avatar

Watchers

 avatar

Forkers

masambo1436 frla

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.