spring-boot-request-respons.../README.md

2.4 KiB

LoggingTestAPIController.java

logging test - get w/ body

curl -X GET 'http://localhost:20090/api/v1/loggingTest/getWithBody' \
--header 'Content-Type: application/json' \
--data '{

    "value1" : "v1!",
    "value2" : 123,
    "value3" : false
}'

logging test - get w/ param

curl http://localhost:20090/api/v1/loggingTest/get?p1=v1&p2=v2

logging test - post w/o body, w/ error

curl -X POST 'http://localhost:20090/api/v1/loggingTest/postWithBody'

logging test - post w/ body

curl -X POST 'http://localhost:20090/api/v1/loggingTest/postWithBody' \
--header 'Content-Type: application/json' \
--data '{
    "value1" : "valu1!",
    "value2" : 1111111,
    "value3" : true
}'

Appendix

schema.sql for other dbms

mysql

create table request_log
(
    id               bigint auto_increment primary key,
    application_name varchar(64),
    http_method      varchar(255),
    uri              varchar(255),
    query_string     varchar(2047),
    content_type     varchar(255),
    body             mediumtext,
    requested_at     timestamp(6),
    trace_id         varchar(40),
    created_at       timestamp(6),
    primary key (id)
);

create table response_log
(
    id               bigint auto_increment primary key,
    application_name varchar(64),
    http_status      integer,
    content_type     varchar(255),
    body             mediumtext,
    responded_at     timestamp(6),
    trace_id         varchar(40),
    created_at       timestamp(6),
    primary key (id)
);

postgresql

create table request_log
(
    id               bigint generated by default as identity primary key,
    application_name varchar(64),
    http_method      varchar(255),
    uri              varchar(255),
    query_string     varchar(255),
    content_type     varchar(255),
    body             text,
    requested_at     timestamp(6) with time zone,
    trace_id         varchar(40),
    created_at       timestamp(6) with time zone
);

create table response_log
(
    id               bigint generated by default as identity primary key,
    application_name varchar(64),
    http_status      integer,
    content_type     varchar(255),
    body             text,
    responded_at     timestamp(6) with time zone,
    trace_id         varchar(40),
    created_at       timestamp(6) with time zone
);