Comments (4)
There's the easy way of just calling chi.URLParam
to get the path parameter directly from the the request object.
Making a new middleware like pagination won't work with SendSystemMessageToConnectedClient
. That already has an auth middleware that changes the function signature. It can't be chained cleanly with another one that does the same.
There's a better way to just use the Context
. Store values there so it persists across an arbitrary number of middlewares. No need to introduce changed function signatures.
from owncast.
Sounds like the pagination is a different topic. I haven't looked into that. I'll file a new issue.
from owncast.
Bit of a misunderstanding. To clarify, its more to do with design than anything being broken or non-functional.
Pagination works but the middleware directly queries the params from the request object instead of taking the arguments set in the handler, for example:
Line 78 in ae76abb
The params
argument is set by the new generated router and contains both the limit and offset args. It is ignored, which seems incorrect to me. Currently the pagination middleware just takes it from a standard r.Query().Get()
call. The equivalent for the path params would just be the chi.URLParam()
I mentioned. With this the userId
and clientId
params would go ignored:
owncast/handler/integrations.go
Line 22 in ae76abb
The generated router already surfaces this once, seems wasteful to do it again, but wouldn't exactly break anything.
The problem is more the incompatibility of chaining stuff like:
with this:
owncast/router/middleware/auth.go
Line 15 in ae76abb
They work as their own ends of a chain, but if they need to be chained (like a hypothetical path parameter handler that is wrapped around the externalAPIUser auth middleware), it won't be clean. One would have to know about the other since the controller function would need to surface the other's params to be called.
They can't wrap each other since neither can accept a standard HandlerFunc
with only the writer and request, but do return that.
They're more "end"-wares than middle, is my problem.
RequireExternalAPIAccessToken(scope, HandlePagination(dummy_func))(w, r)
won't work since the Access expects a ExternalAccessTokenHandlerFunc
instead of a HandlerFunc
or
HandlePagination(ScopedRequireExternalAPIAccessToken(dummy_func))(w, r)
which also won't work since the pagination expects a PaginatedHandlerFunc
instead of a HandlerFunc
We could ignore it for this case, but what happens if there's ever an endpoint that needs both pagination and and external API access?
The controller would look like:
func (int, int, user.ExternalAPIUser, responseWriter, Request)
Using contexts, we can simply use that to pass values around instead, and middlewares don't need to create these custom types to deal with specific arguments and can all just take and return just the writer and request objects.
from owncast.
I see what you're saying. We could remove the pagination middleware, as it is there primarily for convenience, and just export a similar version as a utility function that can be used in handlers that require pagination. The result would be the same, the logic for pulling out those values would just be done in a different place.
from owncast.
Related Issues (20)
- Support remote lookups of webfinger accounts and autolink them in outbound Fediverse posts HOT 1
- Any stream I watch buffers every 5 seconds HOT 3
- aria live: user name remains logged in name
- aria live: html entities are not decoded
- New offline embed state not handling HTML HOT 4
- New offline embed has overflow problems HOT 3
- [Feature] Add 2FA to Admin Authentication HOT 1
- Audio streaming only (feature request) HOT 2
- Update project to Go 1.22
- Auth related integration tests are flaky and needs to be looked into why they're failing HOT 1
- Total number of viewers -ever (feature request) HOT 5
- Allow image upload in chat HOT 4
- Binary was compiled with 'CGO_ENABLED=0', go-sqlite3 requires cgo to work. This is a stub HOT 3
- [Feature Request] External Chat Filter HOT 1
- Live streams that are between 24 and 25 hours display the time as "Live for 1 day undefined hours" HOT 2
- Write documentation around the OpenAPI spec-based API layer
- Validate and troubleshoot any issues dealing with the pagination middleware after the router change
- Documentation broken link: https://www.kiloview.com/en/encoder/h264-wired/ HOT 2
- Migrate suite of automated browser tests to our new LambdaTest account HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from owncast.