Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] Add views/view controllers #221

Closed
sansyrox opened this issue Jul 2, 2022 · 1 comment · Fixed by #407
Closed

[Feature Request] Add views/view controllers #221

sansyrox opened this issue Jul 2, 2022 · 1 comment · Fixed by #407

Comments

@sansyrox
Copy link
Member

sansyrox commented Jul 2, 2022

Current Behavior

Right now, you can only use per route decorators.

Desired Behavior

Add the ability to add views. Views will allow the ability to better structure the code. As you can have all the different kind of routes(GET/POST/PUT....) for the same route under a single class.

High Level Implementation

  • Create a add_view class/protcol
  • Handle and call the python interface functions.

Screenshots / Mockups

Alternatives


@sansyrox sansyrox changed the title [Feature Request] Add the ability to add views [Feature Request] Add views/view controllers Jul 26, 2022
@sansyrox
Copy link
Member Author

sansyrox commented Aug 2, 2022

In addition to generic(Class like) views, add the ability to add views from nested functions.

We can use nestd to extract the function

def view():
	def get():
		return "hello, world"

	def post():
		return "hello, post"

And in the main file

from robyn.view import view

app.add_view("/route", view)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant