173 Commits

Author SHA1 Message Date
Bob Farrell
11fc43b8ce WIP 2024-11-09 17:13:32 +00:00
Bob Farrell
748710f369 WIP
Actions:

+

Motivation:

+
2024-11-09 17:13:32 +00:00
Bob Farrell
5c5e2fa192 WIP 2024-11-09 17:13:32 +00:00
Bob Farrell
55f7bebb9e WIP 2024-11-09 17:13:32 +00:00
Bob Farrell
058a82582a WIP 2024-11-09 17:13:32 +00:00
Bob Farrell
b179007344 WIP 2024-11-09 17:13:25 +00:00
Bob Farrell
198754eef2 WIP 2024-11-09 17:12:49 +00:00
Bob Farrell
9bc1b26c10 WIP 2024-11-09 17:12:49 +00:00
Bob Farrell
bd15e5c43b WIP 2024-11-09 17:12:49 +00:00
Bob Farrell
94ce83b425 Update Zmpl - @for fixes and partial arg type coercion 2024-11-08 19:42:39 +00:00
Bob Farrell
c7b79f144a Fixes for https://github.com/ziglang/zig/pull/21817 2024-11-06 08:44:07 +00:00
IbrahimOuhamou
d5078cc617 added 'session.save()' inside 'session.remove()' thanks to Allah 2024-11-03 13:08:43 +01:00
IbrahimOuhamou
cea2781391 updated zmpl and added session.remove() thanks to Allah 2024-11-03 11:39:03 +01:00
Bob Farrell
f971f18a60 Global data
Define `pub const Global = SomeType` at top level in `src/main.zig`,
then create a pointer to `SomeType` and pass to `app.start`:

```
app.start(routes, .{ .global = global });
```

Then access in a view as `request.global`.
2024-10-28 09:07:06 +00:00
Bob Farrell
9e4a81aa19 Closes #105: Configure SMTP from environment variables
Fall back to hardcoded values if each `JETZIG_SMTP_*` variable is not
present.
2024-10-17 22:09:04 +01:00
Bob Farrell
9b2d6274ff Update http.zig
Resolves overflow vuln.
2024-09-27 18:27:22 +01:00
Bob Farrell
15b0fa1af9 Latest Zig master compatibility 2024-08-30 18:43:12 +01:00
Bob Farrell
e98c5ec3df Update http.zig
Refactor routes generation to standalone exe (fixes some build-time vs.
run-time issues).
2024-08-24 11:18:08 +01:00
Bob Farrell
32da79ca21 Fixes #96: Trim module name properly 2024-08-15 18:02:55 +01:00
Bob Farrell
f0c7475386 Provide default value for Route.formats 2024-08-10 18:39:28 +01:00
Bob Farrell
1406447f24 Implement response format constraints
Define `pub const formats` in a view to specify which formats are
available. Use this to e.g. disable JSON responses.
2024-08-04 16:06:39 +01:00
Bob Farrell
9971cde875 Close #89: Implement file upload support
Use `request.file("form-field-name")` to try to find a multipart-encoded
form value for the given name. Returns `jetzig.http.File` if a match is
found which provides `content` (uploaded file content) and `filename`
(filename as passed by browser).
2024-06-19 20:47:05 +01:00
Dustin
33e76d74ad Fix nested paths in public folder on windows 2024-06-11 16:27:24 -06:00
Dustin
6ee43f7c9f Fix nested paths in public folder on windows 2024-06-11 16:08:00 -06:00
Bob Farrell
3882eba2f3 Clean up static params and init script 2024-06-09 11:13:33 +01:00
Bob Farrell
e30d340a7a Embed static routes in compiled exe
Remove need for static routes output files to be copied/generated in
deployment.
2024-06-08 19:37:41 +01:00
Bob Farrell
2d921a1c27 Add jetzig routes command
Output all current routes. Invokes `zig build jetzig:routes`.
2024-06-05 21:26:23 +01:00
rhues
cea262e066 Fixed issue 52 by using only native Windows colors on Windows. This should fix log colorization for all Windows terminals. Note: when Zig 0.12 support is no longer needed, a much more elegant solution is possible that allows ANSI colors on Windows. This fix works with Zig 0.12 and up. 2024-06-04 08:17:14 -07:00
Bob Farrell
a46bc0ed19 Test helpers
Add `jetzig test` command which runs build step `jetzig:test`.

Add `jetzig.testing` namespace which provides test helpers and a test
app.

Add tests to view generator (i.e. include tests for generated routes).
2024-06-03 21:56:32 +01:00
Bob Farrell
b7af4a396e Fix missing public declaration 2024-06-01 18:11:44 +01:00
Bob Farrell
b304a3509b Windows compatibility fixes 2024-06-01 18:05:01 +01:00
bobf
a6c3e77ddc
Merge pull request #82 from drsneed/main
Added cookie options
2024-06-01 17:23:58 +01:00
Bob Farrell
3875ffbdfb Remove allocs in Headers.getAll()
Provide `Headers.getAllIterator()` to iterate over matching headers, use
this to iterate through `Accept-Encoding` headers in
CompressionMiddleware.
2024-06-01 17:09:49 +01:00
Bob Farrell
7339641401 Refactoring 2024-06-01 16:20:16 +01:00
Froxcey
f538b0ddce Fix Compression Middleware
Checks "Accept-Encoding" header, add deflate encoding, rename the
middleware, and avoid unnecessary encoding.
2024-06-01 16:17:45 +01:00
Froxcey
ae44b1b21a Add gzip middleware 2024-06-01 16:17:45 +01:00
Bob Farrell
35a2b8a006 Refactor to reduce allocs, add tests for cookie flags 2024-06-01 15:25:24 +01:00
Dustin
02fd62b415 Removed unnecessary allocation 2024-05-30 17:41:02 -06:00
Dustin
5a6ea71ab9 Added cookie options 2024-05-30 16:46:18 -06:00
Bob Farrell
a0faada748 Closes #79 - Use response arena for allocs 2024-05-28 18:06:06 +01:00
Bob Farrell
887e4e551b Middleware request resolution
Allow middleware to resolve a request by calling `request.redirect` or
`request.render` - after this point, the request stops processing and
renders immediately.
2024-05-27 16:38:11 +01:00
Bob Farrell
b6b67f8dd6 Use http.zig arena pool 2024-05-26 21:37:48 +01:00
Bob Farrell
80ca764c0f Update Zmpl for template inheritance
Permit setting template during view render with `request.setTemplate()`

Permit middleware to define custom routes to static content with
`pub const Routes` (implemented for something no longer needed but seems
useful anyway).

Implement globbing on custom routes, `/foo/:bar*` will glob all path
segments including and after `/foo/...`, e.g. `/foo/bar/baz/qux` will
pass invoke the custom view function with an array of `bar`, `baz`,
`qux` as first argument (instead of typical resource ID).
2024-05-26 17:20:21 +01:00
Bob Farrell
77794cd34d Implement custom routes
In `main()`:

```zig
    app.route(.GET, "/custom/:id/foo/bar", @import("app/views/custom/foo.zig"), .bar);
```

Routes `GET` request with path (e.g.) `/custom/1234/foo/bar` to `bar()`
defined in `src/app/views/custom/foo.zig`.

Routes with an `:id` segment expect a function with three parameters,
routes without an `:id` segment expect a function with two parameters
(i.e. the same as `get` vs `index`).
2024-05-22 20:49:41 +01:00
Bob Farrell
3519483f34 Switch to http.zig
Use Karl Seguin's http.zig as HTTP server backend:
https://github.com/karlseguin/http.zig

Update loggers to use new `jetzig.loggers.LogQueue` to offload logging
to a background thread.

Numerous other optimizations to remove unneeded allocs.

Performance jump on a simple request from approx. 2k requests/second to
approx. 40k requests/second (Intel(R) Core(TM) i7-6700K CPU @ 4.00GHz).

Color support for Windows

Zmpl partial arg type coercion
2024-05-12 21:33:26 +01:00
Bob Farrell
65edd20092 Allow mailers to modify mail template params
Remove need to add all mail template params to view response data. This
was originally intended functionality but the wrong value was passed to
the `deliver` function, and no `data` argument was given, making it
cumbersome to create new values.
2024-05-05 20:04:57 +01:00
Bob Farrell
b7d750c54f Formalise JetKV interface for store, cache, jobs
Provide configuration for JetKV backend (memory or file allocator).
2024-05-05 12:27:59 +01:00
Bob Farrell
19da5362cf Merge branch 'fix-session-nonce-re-use' 2024-05-02 18:50:52 +01:00
Bob Farrell
439a0c1206 Add bounds check for session decrypt data 2024-05-02 18:48:47 +01:00
Bob Farrell
33a1596238 Remove debug print 2024-05-01 21:30:53 +01:00