nomasystems / erf

:pencil: A design-first Erlang REST Framework.
https://nomasystems.github.io/erf/
Apache License 2.0
29 stars 2 forks source link

refactor: update request data structure #57

Closed javiergarea closed 9 months ago

javiergarea commented 9 months ago

Currently, requests are represented using different data structures in both middlewares and routers. This current structure is too rigid, making it challenging to implement enhancements without introducing breaking changes. Therefore, we should standardize these representations and adopt a more flexible approach.

e.g.,

%%% BEFORE

% Middlewares
-type request() :: {
    Path :: [binary()],
    Method :: method(),
    QueryParameters :: [query_parameter()],
    Headers :: [header()],
    Body :: body()
}.

% Routers
operation_id(PathParameters, QueryParameters, Headers, Body) ->
%%% AFTER

% Both middlewares and routers
-type request() :: {
    path := [binary()],
    method := method(),
    query_parameters := [query_parameter()],
    headers := [header()],
    body := body()
}.