Giter Club home page Giter Club logo

clog-lack-session's Introduction

Clog-Lack-Session

For using lack-middleware-session in CLOG

Usage

(clog:initialize 'SOME-HANDLER
                 :lack-middleware-list `(,lack.middleware.session:*lack-middleware-session*
                                         ,clog-lack-session:*middleware*))

Then, you can use (clog-lack-session:current-session clog-obj) to get the server-side session as a hash-table

Sample code

In your CLOG app, you can gethash to retrieve/setf server-side session based current user data

(gethash :current-user
         (clog-lack-session:current-session clog-obj))

With the following code, when a user visit the root path "/" without corresponding current user data, the user can only see "I'm a static front page."

(clog:initialize nil
                 :lack-middleware-list `(,lack.middleware.session:*lack-middleware-session*
                                         ,clog-lack-session:*middleware*
                                         ,(lambda (app)
                                            (lambda (env)
                                              (cond ((and (string= (getf env
                                                                         :path-info)
                                                                   "/")
                                                          (null (gethash :current-user
                                                                         (getf env
                                                                               :lack.session))))
                                                     `(200 (:content-type "text/plain")
                                                           ("I'm a static front page.")))
                                                    (t
                                                     (funcall app env)))))))

Installation

$ ros install shakatoday/clog-lack-session

local-project

$ cd PATH-TO-YOUR-QUICKLISP-LOCAL-PROJECT
$ git clone https://github.com/shakatoday/clog-lack-session.git

Then quicklisp can find it.

Warning

It currently uses document.cookie API. You can't turn on HttpOnly for cookie. I'll find another way so it won't call document.cookie in the future.

Author

Copyright

Copyright (c) 2022 Shaka Chen ([email protected])

License

Licensed under the BSD 3-Clause License.

clog-lack-session's People

Contributors

shakatoday avatar

Stargazers

Józef Piątkiewicz avatar

Watchers

 avatar

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.