Git Product home page Git Product logo

restas's Introduction

RESTAS is a Common Lisp web application framework. Its key features are:

  • RESTAS was developed to simplify development of web applications following the REST architectural style.
  • RESTAS is based on the Hunchentoot HTTP server. Web application development with RESTAS is in many ways simpler than with Hunchentoot, but some knowledge of Hunchentoot is required, at least about working with hunchentoot:request and hunchentoot:reply.
  • Request dispatch is based on a route system. The route system is the key concept of RESTAS and provides unique features not found in other web frameworks.
  • The other key RESTAS concept is its module system, which provides a simple and flexible mechanism for modularized code reuse.
  • Interactive development support. Any RESTAS code (such as the definition of a route, a module or a submodule) can be recompiled at any time when you work in SLIME and any changes you made can be immediately seen in the browser. No web server restart or other complicated actions are needed.
  • SLIME integration. The inner structure of a web application can be investigated with the standard "SLIME Inspector." For example, there is a "site map" and a simple code navigation with this map.
  • Easy to use, pure Lisp web application daemonization facility based on RESTAS and SBCL in Linux without the use of Screen or detachtty.
  • RESTAS is not an MVC framework, although it is not incompatible with the concept. From the MVC point of view, RESTAS provides the controller level. Nevertheless, RESTAS provides an effective and flexible way for separation of logic and representation, because it does not put any constraints on the structure of applications. Separation of model and controller can be effectively performed with Common Lisp facilities, and, hence, doesn't need any special support from the framework.
  • RESTAS does not come with a templating library. cl-closure-template and HTML-TEMPLATE are two good templating libraries that can be used with RESTAS.

RESTAS is distributed under the terms of the Lisp LGPL license.

restas's People

Contributors

alexey-martynov avatar archimag avatar christophejunke avatar cmpitg avatar dym avatar euandreh avatar linkfly avatar menschenkindlein avatar orivej avatar peterwang avatar ska80 avatar tmccombs avatar turtle-bazon avatar valera avatar zhef avatar zodmaner avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

restas's Issues

Request: autogenerate site-map

It would be useful, at least, for debugging routes configuration, if restas was able to generate a tree of all possible routes, registered in the system.

Update

This is really nice, are you still maintaining this repo?

A way to set the render method of a module

I need to be able to set the render method of a module from within the module, doing it in define-module or mount-module would be inconvenient. After 10 minutes with the source, I came up with this hack:

(defun set-render-method (method &optional (package *package*))
  (let ((traits (gethash (find-package package) restas::*pkgmodules-traits*)))
    (setf (gethash :render-method traits)
      (alexandria:named-lambda make-render-method () method)))
  (restas:reconnect-all-routes))

Is there a better way? I could implement something better and send a pull request, but I don't quite understand the implementation of the new module system yet.

more examples about publishing static files are required

Dear Andrey,
sorry to disturb you, I got trapped in how to use RESTAS to publisher an exist file,such as .html . .txt etc.Even though a package which called "restas.file-publisher",I couldn't use it properly,so as I 'm a newbee about lisp usage to do practical works,
Please give me a hand and give me more examples about publishing static files,
Your sincerely ,
lisper 03

Request: context-dependent functions

It would be nice to have a macros (e. g. cdefun) like define-route, but defining a generic function, which takes an additional argument - the submodule-designated symbol. Each mount-submodule also generate methods for those function, specialized for the symbol, specified in it. Those methods will just put the code of the function into the submodule context, with all dynamically scoped variables will seem like the function is called from a route of this submodule. For example:

; mod1:

(defvar *var* 0)
(cdefun add-var (a) (+ *var* x) ) ; <-- the function here depend on dynamically scoped context

; mod2:

(mount-submodule sm1 (#:mod1) ; <-- Create two different contexts
   (mod1:*var* 1))                         ;     /
(mount-submodule sm2 (#:mod1) ; <-
   (mod1:*var* 2))

; Call function in different contexts
(mod1:add-var 'sm1 1) ;--> 2
(mod1:add-var 'sm2 1) ;--> 3

;mod3:

(mount-submodule sm1 (#:mod1)
  (mod1:*var* 41))

(mod1:add-var 'sm1 1) ;--> 42

Here the first invocation and the third will refer to the different methods, because the symbols mod2:sm1 and mos3:sm1 are different.

I know one way to achieve such results now -- using the restas:with-context macro. But it is quite verbose (and undocumented, as far as I know):

(restas:with-context (second (gethash 'sm1 *submodules*))
   (mod1:add-var 1))

And it still handles restas:genurl improperly (relative to the current module, not to the 'sm1).
It's just a proposal, may be there is a more elegant solution.

Possibly confusing handling of default values in define-policy

When calling define-policy, the keyword arguments in %define-policy that were absent in define-policy are set to NIL, and do not take their default values. This can lead to errors when the NIL value is not meaningful for that option, as described in this question: https://stackoverflow.com/q/58257183/124319

There are different fixes possible, that basically boils down to handling NIL values in %define-policy or preventing the define-policy macro from giving keyword arguments when they are nil. I am not submitting a patch at the moment because I am not sure about which way seems better for you.

case :render-method issue in define module

Hello,

I am trying to figure out why this issue appeared:
archimag/restas-directory-publisher#7
I think changing this function

https://github.com/archimag/restas/blob/master/src/route.lisp#L27

with

(defun` route-render-method (route)
  (funcall (or (slot-value route 'render-method)
               (and (module-render-method (route-module route))
		    #'(lambda () (module-render-method (route-module route))))
               (lambda () #'identity))))

resolve the rendering issue; but because i am not able to understand the internal machinery of the library i can not consider this a solution for that bug, just an hint. I hope can be useful anyway.

Bye!
C.

Fix for gen-full-url uri scheme

I have prepared a small patch that fixes the assumption that all urls use the :http uri scheme

From 8deaa520518d8c24e4fb140929d36c3e90ac9fd3 Mon Sep 17 00:00:00 2001
From: Brian Hollis <[email protected]>
Date: Sun, 26 Feb 2012 01:11:22 -0600
Subject: [PATCH] Modified gen-full-url to detect bound ssl acceptor and set
 uri scheme accordingly.

---
 src/route.lisp |   14 ++++++++------
 1 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/src/route.lisp b/src/route.lisp
index 6c3cea1..a4fe5c6 100644
--- a/src/route.lisp
+++ b/src/route.lisp
@@ -211,12 +211,14 @@
                                        (submodule-full-baseurl *submodule*)
                                        (route-symbol-template route))
                           args)))
-    (setf (puri:uri-scheme uri)
-          :http)
-    (setf (puri:uri-host uri)
-          (if (boundp 'hunchentoot:*request*)
-                      (hunchentoot:host)
-                      "localhost"))
+
+    (if (boundp 'hunchentoot:*request*)
+       (setf (puri:uri-scheme uri) (if (hunchentoot:ssl-p) :https :http)
+             (puri:uri-host uri) (hunchentoot:host))
+
+       (setf (puri:uri-scheme uri) :http
+             (puri:uri-host uri) "localhost"))
+
     (puri:render-uri uri nil)))

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
--
1.7.6.4

Decorators are lost when module is mounted

Decorators defined on define-route are lost when this module is mounted as sub-module into other module.

My simplified situation is like this:

packages.lisp

(restas:define-module #:test
  (:use #:cl))

(restas:define-module #:test.admin
  (:use #:cl))

admin.lisp

(in-package #:test.admin)

(defclass login-required-route (routes:proxy-route) ())
(defmethod restas:process-route ((route login-required-route) bindings)
  (break)) ;; Not breaking
(defun @login-required (route)
  (make-instance 'login-required-route :target route))

(restas:define-route admin-index ("")
  (:decorators '@login-required)
  "In admin")

test.lisp

(in-package #:test)

(restas:mount-module admin (#:test.admin)
  (:url "admin"))

Going to /admin/ is not actually breaking in this case.

routes are tangled

Here is a simple RESTAS application:

(require 'asdf)

(asdf:operate 'asdf:load-op '#:restas)
(restas:define-module #:pack
   (:use #:cl))

(in-package #:pack)
(restas:define-route route ("file/*path" :method :get) (format nil "~a - path" path))
(restas:define-route person-change-route ("person:(id)")
                                    (format nil "~a - person" id))

(restas:define-route nooa ("impossible:(siid)" :method :get) (format nil "~a - imposible" siid))

(restas:start '#:pack :port 8080)

If it is runned on sbcl 1.0.54, hunchentoot 1.2.2, RESTAS 20111203-git, produces strange begaviour:
http://localhost:8080/person1 ---> NIL - imposible
It goes by the wrong, third, route.
If you comment first, or last route, your will receive:
http://localhost:8080/person1 ---> 1 - person

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.