Code Monkey home page Code Monkey logo

Comments (2)

essenciary avatar essenciary commented on July 22, 2024

First of all, Happy New Year!
Decided to scratch my own itch.
It's now possible to do things like:

       get(
            "/hellos/new", 
            req -> new(Hellos_Controller(), req)
            ),
        get(
                "/hellos/:id", 
                req -> show(Hellos_Controller(), req)
            ),
        get(
            "/hellos/:id/edit", 
            req -> edit(Hellos_Controller(), req)
            ),
        get( 
            "/hellos", 
            req -> index(Hellos_Controller(), req)
            ),
        post(
            "/hellos", 
            req -> create(Hellos_Controller(), req)
            ),
        put(
            "/hellos/:id", 
            req -> update(Hellos_Controller(), req)
            ),
        delete(
            "/hellos/:id", 
            req -> destroy(Hellos_Controller(), req)
            )

and

@resources("hellos")..., 

which is automatically expanded into the above.

The macro also supports

@resources("photos", [:index, :show, :edit, :create])...

where the array represents the allowed methods (will generate only them)
or

@resources("photos", [], [:delete, :update])..., 

where the second array represents the excepted methods (will generate all but them).

I would've liked to be able to skip the empty array - it would've been nice if macros allowed keyword arguments but that doesn't seem to work. Will simulate by passing in a Dict.

I implemented this in my module but if there's any interest, I can merge it with the Mux codebase.

from mux.jl.

essenciary avatar essenciary commented on July 22, 2024

Closing this for lack of feedback. If support for resources will come up on the TODO list for the project, I'll be happy to contribute.

from mux.jl.

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.