Ability to declare HTTP resources #3
Labels
No labels
Compat/Breaking
Kind/Bug
Kind/Documentation
Kind/Enhancement
Kind/Feature
Kind/Research
Kind/Security
Kind/Testing
Priority
Critical
Priority
High
Priority
Low
Priority
Medium
Reviewed
Confirmed
Reviewed
Duplicate
Reviewed
Invalid
Reviewed
Won't Fix
Status
Abandoned
Status
Blocked
Status
Need More Info
No project
No assignees
1 participant
Notifications
Total time spent: 1 day 12 hours
Due date
c.fahner
1 day 12 hours
No due date set.
Blocks
#1 Request/response flow
slendium/framework
#14 Public API for Resource behavior metadata
slendium/framework
Reference
slendium/framework#3
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Modules should be able to declare HTTP resources. Each resource can respond differently based on the HTTP method. Supported query or body arguments are declared as function parameters and filled in using reflection.
Resources exposed by modules exist in a fixed namespace called
Resourcesrelative to theModuleimplementation to avoid having to keep track of all possible routes in a big centralized map. The filesystem itself basically becomes the routing table. Every incoming request is mapped to a resource based on implementation-defined (or even user-defined) routing rules. A basic implementation could simply map the URLs' path to a class name.Links to other HTTP resources on the system can be declared in a type-safe manner by referencing the
class-string<Resource>. This has the additional benefit of auto-detecting broken internal links through static analysis of the code and makes switching between front-end (HTML-generating) code and back-end code as easy as just following the class reference.c.fahner referenced this issue2026-05-28 07:05:13 +02:00
Doing a small refactor of the work so far, both to incorporate #14 and to introduce some more parts into the current design.
The current API has no ability to express response variants for the same resource method. This makes it difficult to declare the possible response status codes, content types and body schemas with something like OpenAPI.
The current plan is to remove the
#[Method]annotation and turn it into an interface. Classes implementing this interface can then decorate theirResponse-returning methods with annotations, for example:Both the
#[Status]and#[Content]annotations should inherit from a common interface to allow for more custom descriptors. Having these descriptors for each possible "branch" of the method will also help with fuzzing. A potential 400 status code is implied for any method that requires at least one argument.Additionally it should be possible to express that while a
Resourceimplements a certain HTTP method, it might not be available at runtime for all contexts (due to a lack of permissions for example).Example resource using the planned API design: