Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Implementation:APIJSON APIJSON Demo DemoController SimpleDemo

From Leeroopedia
Knowledge Sources
Domains Web_Framework, API_Design, Authentication
Last Updated 2026-10-14 00:00 GMT

Overview

Concrete tool for routing HTTP requests to CRUD operations with full login/logout authentication implementation in the APIJSON SimpleDemo Spring Boot 3 variant.

Description

The DemoController class (SimpleDemo variant) extends APIJSONController<Long> and provides CRUD endpoints plus a complete login implementation that validates username/password, looks up the Privacy model, verifies credentials via HEADS requests, and stores session state. It also implements logout with session invalidation and user ID extraction. Uses jakarta.servlet (Spring Boot 3).

Usage

Use this controller when deploying the APIJSON SimpleDemo Spring Boot 3 server with authentication.

Code Reference

Source Location

Signature

@RestController
public class DemoController extends APIJSONController<Long> {
    @Override
    public Parser<Long> newParser(HttpSession session, RequestMethod method);
    @PostMapping("{method}")
    @Override
    public String crud(@PathVariable String method, @RequestBody String request, HttpSession session);
    @PostMapping("{method}/{tag}")
    @Override
    public String crudByTag(@PathVariable String method, @PathVariable String tag,
            @RequestParam Map<String, String> params, @RequestBody String request, HttpSession session);
    @PostMapping("login")
    public JSONObject login(@RequestBody String request, HttpSession session);
    @PostMapping("logout")
    @Override
    public JSONObject logout(HttpSession session);
}

Import

import com.example.apijsondemo.controller.DemoController;

I/O Contract

Inputs

Name Type Required Description
request String Yes JSON request body
session HttpSession Yes HTTP session for auth state

Outputs

Name Type Description
login() returns JSONObject Auth result with user ID and session state
logout() returns JSONObject Logout success response
crud() returns String JSON response from APIJSON parser

Usage Examples

Login Flow

# Login request
curl -X POST http://localhost:8080/login \
  -H "Content-Type: application/json" \
  -d '{"username":"test","password":"123456"}'

# Response: { "code": 200, "Privacy": { "id": 82001, ... } }

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment