Commit graph

150 commits

Author SHA1 Message Date
Yorhel
65cf842500 FU: Some fixes and consistency in fu->json and fu->formdata 2025-03-16 18:26:57 +01:00
Yorhel
3382deba9a Validate: Rename "scalar" to "accept_scalar" and add "accept_array" 2025-03-16 15:39:10 +01:00
Yorhel
f8fe53cba9 json_format: Add html_safe option 2025-03-16 15:03:32 +01:00
Yorhel
3fad7feec3 Validate: Rename "values"->"elems", repurpose "values" to validate hash values
I'm breaking stuff left and right while I still can.

Idea: "key_names" validation?

Idea: "tuple" validation that works like "keys" but for arrays.
  (i.e. { tuple => { $index => $schema } }, could make "missing" and
  "unknown" work for arrays, too)
2025-03-14 16:52:33 +01:00
Yorhel
fa24ca53e3 Validate: improved arrayref-schema semantics
This allows all built-in options to be duplicated inside a single
schema, the semantics of which are the same as the kind of merging
done as part of inheriting options from custom validations.

This also causes all 'keys' and 'values' validation schemas to be
merged, which changes error messages a bit but is great for
introspection. Probably slightly improves performance as well.
2025-03-14 14:28:28 +01:00
Yorhel
cea691dd55 Validate: drop creation of default values for built-ins
To better support merging multiple validations, which'll come next.
Probably.
2025-03-14 10:52:12 +01:00
Yorhel
f248a33c1c Validate: Allow multiple func validations in arrayref schema 2025-03-14 09:25:56 +01:00
Yorhel
1363e11269 Validate: allow array schemas + defer known_keys hash creation
Doesn't allow multiple 'func' options yet, needs work.
2025-03-14 07:28:11 +01:00
Yorhel
64a105e013 Validate: remove a level of indirection 2025-03-14 07:27:59 +01:00
Yorhel
9685287523 Version 0.3 2025-03-10 12:43:02 +01:00
Yorhel
d9d2ad0434 Pg: Add COPY support 2025-03-10 12:32:14 +01:00
Yorhel
dc752e2a23 Pg: Support dynamic-oid types + vndbtag/vndbid 2025-03-09 10:23:48 +01:00
Yorhel
70c5199df4 FU: Add JSON reading & writing methods 2025-03-08 15:49:43 +01:00
Yorhel
17176738a0 FU: Support multipart file uploads + some doc fixes
API is not super convenient and implementation is lousy, but uploading
files is not a super common operation so that should be fine.

At least it supports large files with only a single in-memory copy.
2025-03-08 14:06:10 +01:00
Yorhel
e5755ddd80 Validate: Human-readable error messages 2025-03-06 10:16:14 +01:00
Yorhel
e4b6b77e1b Validate: rename rmwhitespace to trim and use builtin::trim() 2025-03-05 15:39:49 +01:00
Yorhel
cbebc3a21e Validate: Rework API, ->validate() now throws error instead of result object
This is a slight simplification and removes the need to pass around
partially normalized data. I've never found a use for the unsafe_data()
method.
2025-03-05 15:35:23 +01:00
Yorhel
7839e7df78 FU: Fix typo in error handling 2025-03-02 21:09:59 +01:00
Yorhel
f09a103c53 Some test portability fixes again + minor changes 2025-03-02 10:10:35 +01:00
Yorhel
3fd424c6e3 Compat fixes + 0.2 release 2025-02-28 14:05:48 +01:00
Yorhel
15954f4ad5 Pg: Add "$hex" pseudo-type 2025-02-28 13:49:07 +01:00
Yorhel
baf0f90bd5 Pg: Add "time" type, change default format of "date" type but support "$date_str"
Using a consistent numeric interpretation for timestamps, dates and
times simplifies a bunch of operations. It certainly simplifies
conversion between the Postgres formats.
2025-02-28 13:03:16 +01:00
Yorhel
0734bc4991 Pg: Skip query preparation when we can 2025-02-28 12:33:30 +01:00
Yorhel
4686097d00 Pg: Support custom type overrides with callbacks 2025-02-28 11:23:42 +01:00
Yorhel
327fd9ea50 Pg: Support type override configuration 2025-02-27 18:24:14 +01:00
Yorhel
3662931fc2 FU: Add "denied" and "notfound" convenience methods 2025-02-27 14:00:28 +01:00
Yorhel
b06cc24826 FU: Add super awesome and butt-ugly FU::debug_info web interface
This is so much more useful than embedding debugging info inside pages,
as I've been doing before.
2025-02-27 13:44:25 +01:00
Yorhel
de36b90cde Fixes for longdouble perl builds
Mostly test fixes, but the Pg 'timestamp' type did have a small
conversion bug.
2025-02-27 09:35:15 +01:00
Yorhel
8dca0a22a9 FU: Add randomized --max-reqs option 2025-02-26 11:31:15 +01:00
Yorhel
29dd09e809 FU: Drop Zstd support
Compress::Zstd decided to bundle libzstd instead of linking to the
system lib, and it predictably hasn't been updated in 6 years. I
consider that broken to the point of DO-NOT-USE.

Maybe I'll do a custom dlopen() wrapper for that later, but for now
let's just stick with gzip.
2025-02-26 08:59:36 +01:00
Yorhel
43928b91e8 Fix two memory leaks 2025-02-26 08:53:16 +01:00
Yorhel
0c59b56ee8 Minor doc & portability fixes 2025-02-26 08:06:57 +01:00
Yorhel
7b0ba45346 Docs, compatibility fixes again, 0.1 release 2025-02-25 17:02:33 +01:00
Yorhel
69262992ca FU::Validate: Add module + integrate with FU
Copied from TUWF::Validate with a few small changes. I have a few more
features planned, but let's see how this goes first.

It's been an incredibly useful module in the past, I'm not sure right
now if I had ideas for potential improvements at some point, will need
to check notes.
2025-02-25 14:31:38 +01:00
Yorhel
c7a3415485 Util: Add to_bool() and use it for JSON, Pg & query encoding
To improve interop with legacy modules.
2025-02-25 09:33:33 +01:00
Yorhel
06e2f950fe Add fu->redirect, change $st->row behavior on 0 results, minor fixes
And with this, I have a working rewrite of the manned.org backend into
FU. \o/

The $st->row methods are very useful even for queries that may not
return anything, so their old behavior was unhelpful. Interestingly
enough, the error-on-multiple-rows did catch an actual bug in
Manned.org, so I'm keeping that behavior.
2025-02-24 15:55:27 +01:00
Yorhel
fbbaa23842 pg: Add date type & httpdate tests
...I was hoping not to have to implement the date type, because date
conversions suck, but it turns out manned.org actually needs it.
(Only to then convert it into a Unix timestamp again, hmm, maybe this
string conversion isn't useful at all?)
2025-02-24 11:54:37 +01:00
Yorhel
8595c4ba64 FU: HTTP date handling + fu->send_file 2025-02-24 11:12:01 +01:00
Yorhel
18e642290d Some fixes and framework docs 2025-02-23 14:05:43 +01:00
Yorhel
b2d676b1ed pg: Add query tracing & prepare/execute time measurements
What I'd really like, in addition to this, is a way to extract a query
from an $st object that can be run in the psql CLI. VNDB has a debugging
feature for that, but it's less trivial to make that work with binary
query parameters.
2025-02-22 15:15:16 +01:00
Yorhel
a5f9584b02 FU::Log: Add logger and basic integration with FU 2025-02-21 17:13:32 +01:00
Yorhel
6f1583ddad pg: timestamp(tz) types + more docs 2025-02-21 12:58:24 +01:00
Yorhel
8036b8f0bf SQL: Doc and test adjustments 2025-02-21 10:22:33 +01:00
Yorhel
145d086bea Add FU::SQL
Somewhat experimental, need to test this approach on a real site.
Looking pretty promising so far, though.
2025-02-20 15:45:55 +01:00
Yorhel
48d3fb86a5 FU: Revert integration with XMLWriter & import options; copyright stuff
Realized that, since html_() now returns a string, it's just as easy to
just pass that to fu->set_body(); no need for integration complexity.

Combined import options don't save much typing, not worth the overhead
either.
2025-02-20 08:46:03 +01:00
Yorhel
d0665ef7c2 FU: Output compression, XMLWriter integration, import options, some docs 2025-02-19 16:55:43 +01:00
Yorhel
63f524622b bench: Re-run with more time + JSON::Tiny & XMLWriter benchmarks 2025-02-19 13:32:28 +01:00
Yorhel
9014e2900c Add FU::XMLWriter
And remove UTF-8 check in JSON writer. It honestly feels kind of silly
to do that validation there while I've never done similar validations in
any other output routines - including this XML writer.

FU::XMLWriter is a copy of TUWF::XMLXS with a bunch of improvements
applied: now uses refcounts to determine the current output instance,
auto-generates XS functions and has faster escaped string output -
inspired by the JSON writer.

TODO:
- Integrate into FU
- Do something with bool attribute values
- Benchmarks
- Should $content be optional for all tags? The reason they weren't in
  TUWF::XMLXS is because TUWF::XML supports opening tags without closing
  them, but that idea turned out to suck and isn't supported anymore.

This is hopefully the last XS module for the FU framework. The only C
code being written now should be bug fixes and extending FU::Pg with
some planned features. Already ended up with more C than I had
planned...
2025-02-19 12:01:24 +01:00
Yorhel
67e6d99f01 Add query string encoding & decoding functions 2025-02-18 14:08:23 +01:00
Yorhel
90cfd66069 FU: Some FastCGI fixes; FU::Util: utf8_decode & URI escaping 2025-02-18 10:27:58 +01:00