Giter VIP home page Giter VIP logo

Comments (9)

rs avatar rs commented on May 14, 2024 2

We may also provide some examples of such usage.

from rest-layer.

smyrman avatar smyrman commented on May 14, 2024

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.

omani avatar omani commented on May 14, 2024

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.

omani avatar omani commented on May 14, 2024

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.

rs avatar rs commented on May 14, 2024

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.

omani avatar omani commented on May 14, 2024

I am using the example auth-jwt.

or do you mean the creation of jwt? (login)

from rest-layer.

omani avatar omani commented on May 14, 2024

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.

smyrman avatar smyrman commented on May 14, 2024

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.

omani avatar omani commented on May 14, 2024

Ok. I think I will rewrite my login route with a new storage handler. thanks.

from rest-layer.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.