Skip to content

v1.18.0

Latest

Choose a tag to compare

@leafo leafo released this 24 Apr 00:04
· 2 commits to master since this release
v1.18.0

HTTP and OpenResty

  • Added lapis.nginx.resty_http, an HTTP client backed by lua-resty-http.
  • lapis.nginx.http now automatically uses the lua-resty-http implementation from timer phase callbacks, where ngx.location.capture is unavailable.
  • Added documentation for HTTPS certificate verification for both the proxy-pass HTTP client and the new lua-resty-http client.
  • The two-argument http.request(url, body) shorthand now sets Content-Length when using the lua-resty-http path.

Models and Database

  • include_in now supports computed key functions returning db.list(...), allowing a single source object to match multiple related rows.

    Tags\include_in pages, {
      name: (page) -> db.list page\get_tag_names!
    }, many: true, as: "tags"
  • include_in preserves transformed values from the value option when assigning results for computed db.list keys.

    Tags\include_in pages, {
      id: (page) -> db.list page.tag_ids
    }, many: true, as: "tag_names", value: (tag) -> tag.name
  • Polymorphic belongs_to preloading now forwards preload options, such as skip_included, to the underlying model preload calls.

    preload items, object: {
      [preload]: {
        skip_included: true
      }
    }
  • Added db.clause + db.clause syntax for combining clauses with OR.

    active = db.clause status: "active"
    invited = db.clause invite_pending: true
    Users\select "where ?", active + invited
  • json_encodable now preserves table metatables, including cjson.array_mt, so empty JSON arrays remain arrays.

    util.to_json {
      items: setmetatable {}, cjson.array_mt
    }
    -- {"items":[]}
  • OrderedPaginator:each_page(...) now accepts an initial cursor.

    pager = Posts\paginated "order by id asc", per_page: 50, ordered: "id"
    for posts in pager\each_page 500
      -- starts after id 500

Testing

  • Added simulate_request and simulate_action as clearer names for request simulation helpers. The old mock_request and mock_action names remain as deprecated aliases.
  • stub_request now sets up request params, GET/POST tables, session, cookies, headers, request method, URL fields, and custom request classes more completely.
  • Request simulation now uses higher-resolution time from LuaSocket.

Application and Flows

  • Requests now expose route_pattern in addition to route_name.
  • Renamed is_flow to is_flow_class to clarify that the helper checks flow classes, not flow instances.
  • Expanded and reorganized the flow documentation.

CLI

  • Third-party command modules can now be resolved directly as top-level commands, so packages no longer need to rely on the generic _ command path.
  • Added a shortcut action for lapis-exceptions.
  • Command discovery now checks module availability without requiring the module, avoiding swallowed load-time errors.

Documentation

  • Reworked the testing documentation around request simulation and stub_request.
  • Added documentation for computed db.list keys in model preloading.
  • Updated utility, flow, and exception handling documentation.