Comments (9)
We may also provide some examples of such usage.
from rest-layer.
rest-layer proclaims itself as an opinionated framework, but you could use only the parts of rest-layer that you need, without using the whole package.
You could for instance rely on the rest-layer/schema
package only. This gives you the data validation capabilities, and you can implement your own logic to route views, fetch data etc.
If you do need the rest-layer/resource
, and or rest-layer/rest
as well, then perhaps it would still be best for you to provide your own implementation/adapter for the Storer interface.
from rest-layer.
my use case is a login route for providing (creating) a JWT (token). as the example auth-jwt says, one has to implement an own login mechanism to handle the creating of a json web token.
and I did that with using "login" as my route in index.Bind() and using the mem storage (mem.NewHandler()) as a pseudo db. but don't need it really since all the logic is in a OnInsert hook for this route.
So I don't really need a storage handler implementing the Storer interface.
from rest-layer.
I thought of something like an abstraction layer like:
index.Route("/path", ...) which gets a handler. just like an http handlerfunc. but with all the benefits of rest-layer.
from rest-layer.
A storage handler is a CRUDL version of a http handler. You could actually create a storage handler instead of using OnInsert
.
Could you show use some of you code you produced to handle JWT? It may be a good way for us to think about easier ways to handle this kind of cases.
from rest-layer.
I am using the example auth-jwt
.
or do you mean the creation of jwt? (login)
from rest-layer.
A storage handler is a CRUDL version of a http handler. You could actually create a storage handler instead of using OnInsert.
now that you say that the storage handler is nothing else than a CRUDL version of a http handler it just clicked in my brain. you are right. the storage handler is meant to be used for such cases.
and now that you say it, I think a better name for a storage handler would be a CRUDL handler. maybe it makes sense to rename Storer
?
from rest-layer.
I think a better name for a storage handler would be a CRUDL handler. maybe it makes sense to rename Storer?
I don't think that renaming the interface is a good idea. The main use case for implementing a Storer is still presumably to provide access to data storage.
If you feel the documentation should be updated to mention CRUDL, that's probably possible, although it should be obvious enough that this is what it is from the list of methods.
from rest-layer.
Ok. I think I will rewrite my login route with a new storage handler. thanks.
from rest-layer.
Related Issues (20)
- Remove old sub-resource syntax HOT 4
- go module: cannot find module providing package testing/mem HOT 3
- Explicit $eq in filter passes whole predicate to Validate(Query) HOT 3
- OnInsert/OnUpdate hooks can modify the new resource item, Etag not recalculated HOT 7
- `Prefer: return=minimal` can hide resource item on server modification HOT 12
- Consistent empty / null fields HOT 4
- Remove resource hooks in favor of resource middleware HOT 12
- Newest `zerolog` versions cause a panic HOT 4
- Bogus error line, when returning empty response on 204
- Etag should not depend on external state HOT 4
- Assist AutoIncrement FieldValidator with SQL backend HOT 8
- How use schema and resource package as standalone HOT 1
- Bulk PATCH support HOT 5
- Wrapping original issue in rest.Error HOT 7
- Feature Request: Cursor-based Pagination HOT 3
- pq: operator does not exist: uuid ~~ unknown HOT 7
- Filter on reference fields HOT 1
- Support for $not filter operation HOT 4
- Decouple ElemMatch from schema.Array struct
- openapi 3.1.0 support 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 rest-layer.