1
0
Fork 0
mirror of https://github.com/zigzap/zap.git synced 2025-10-20 15:14:08 +00:00
Commit graph

33 commits

Author SHA1 Message Date
renerocksai
8078b96d3f add on_uncaught_error behavior to zap.App, add on_error callbacks
zap.Endpont.Listener and zap.App now support on_error callbacks:

zap.Endpont.Listener.Settings contains an `on_error` optional callback
field.

zap.App supports those two callbacks:


/// ```zig
/// const MyContext = struct {
///     // You may (optionally) define the following global handlers:
///     pub fn unhandledRequest(_: *MyContext, _: Allocator, _: Request) anyerror!void {}
///     pub fn unhandledError(_: *MyContext, _: Request, _: anyerror) void {}
/// };
/// ```

The `endpoint` example has been updated to showcase `on_error`, and the
new example `app_errors` showcases `Context.unhandledError`.
2025-04-02 09:53:46 +02:00
renerocksai
8d187310c7 harmonize callback function error handling, zap logging; doc updates 2025-04-01 16:30:24 +02:00
renerocksai
3a2246ba50
cleanup unused params where applicable (ie non-instructive) 2025-03-30 19:58:22 +02:00
renerocksai
cc6d55fbf7
Improved & generalized checkEndpoint functions
E.g. return type's error set does not need to be `anyerror` anymore.
2025-03-30 19:37:40 +02:00
renerocksai
b05004291e refactored endpoint Binder/Bind/Bound/Interface ... namings 2025-03-30 12:21:08 +02:00
renerocksai
51d17a1868 restore lost changes 2025-03-29 11:10:45 +01:00
Rene Schallner
029c8ff069 rename types for endpoint wrapping 2025-03-21 20:08:36 +01:00
Rene Schallner
3aaa7fcc24 removed Self and @This() as much as possible 2025-03-21 18:57:33 +01:00
renerocksai
fcce4517de
introduced error union to request fn return type 2025-03-16 20:16:14 +01:00
renerocksai
7503f090ee
doc update 2025-03-16 16:42:08 +01:00
renerocksai
f77f405320
doc update 2025-03-16 16:33:55 +01:00
renerocksai
3856fceb9f
fix auth tests b/c of new zap.Endpoint 2025-03-16 15:52:26 +01:00
renerocksai
0123e60059
endpoint type check with meaningful error messages 2025-03-16 13:39:01 +01:00
renerocksai
8e80eecc3e
endpoint simplification 2025-03-16 04:45:31 +01:00
Tobias Simetsreiter
3f7492260d zig 0.12.0-dev.3561+f45ba7d0c: remove type argument from fieldParentPtr 2024-04-07 18:21:49 +02:00
Rene Schallner
6d710ba448 use methodAsEnum() in endpoint and json example 2024-02-24 15:52:27 +01:00
Froxcey
694b3196db Use custom method enum 2024-02-23 20:20:00 +01:00
Froxcey
39ee26f9a4 Use std.http.Method for Request.method 2024-02-23 20:16:44 +01:00
John Colvin
a330627b09 s/ednpoint/endpoint/ 2024-01-24 13:59:36 +01:00
Rene Schallner
07c74e757d Refactored request, auth, endpoint:
- zap.Request : refactored into its own file, along with supporting
  types and functions (e.g. http params related)
    - added setContentTypeFromFilename thx @hauleth.
- zap.Auth : zap.Auth.Basic, zap.Auth.BearerSingle, ...
- zap.Endpoint : zap.Endpoint, zap.Endpoint.Authenticating
2024-01-10 15:05:53 +01:00
renerocksai
551d033edc API cleanup #2
--------------

- Middleware: no more MixContexts
    - zig structs are fine
- more documentation (comments -> autodoc).
- websocket docs
2024-01-08 19:26:16 +01:00
renerocksai
3d651229f8 API cleanup #1
--------------

- EndpointListener.register() // was: addEndpoint
- no more Simple
- getEndpoint -> endpoint()
2024-01-08 15:50:46 +01:00
stringnick
1e849d2b05 http method options support 2023-12-31 01:20:54 +01:00
Ed Yu
a641dcc082 add http method PATCH for endpoint listener 2023-05-16 14:58:52 -07:00
Rene Schallner
8067c666b2 on_request fallback for SimpleHttpListener 2023-05-16 03:38:38 +02:00
Rene Schallner
645db5c8d0 AuthResult is now an enum (was: bool) 2023-05-08 00:06:57 +02:00
Rene Schallner
d0c59ab008 fixed AuthEndpoint callbacks, BasicAuth logging
AuthEndpoint callbacks now provide pointers to the original
SimpleEndpoint structs, so their fieldParentPtr calls work.
Added extensive debug() logging to BasicAuth with .UserPassword.
2023-05-01 05:55:08 +02:00
Rene Schallner
b197fb5ff7 housekeeping 2023-04-21 22:18:22 +02:00
Rene Schallner
21550dd6da added unauthorized callback to auth endpoints 2023-04-16 21:23:32 +02:00
Rene Schallner
56121ced9a endpoint auth : sending unauthorized 2023-04-16 20:18:29 +02:00
Rene Schallner
1fa1d10acf started adding HTTP auth + tests 2023-04-16 06:44:14 +02:00
Rene Schallner
9186bb58ec endpoint example: the beginnings 2023-01-14 16:13:14 +01:00
Rene Schallner
becbeb2a3d endpoint stuff progress 2023-01-13 19:55:46 +01:00