Comments (5)
Ah you'd need to add readers to the cookie store implementation for that. We don't provide that by default because people may choose to use different time libraries, but I get why it's problematic... any thoughts @yogthos . Here's a sample snippet from a project I'm using. Of course you can replace tick with your choice of date-time library or just native Java.
(defn wrap-base
[{:keys [cookie-opts]}]
(let [{:keys [cookie-secret cookie-name cookie-default-max-age]} cookie-opts
cookie-store (session.cookie/cookie-store {:key (.getBytes ^String cookie-secret)
:readers {'inst (fn [x]
(some-> x (tick/parse) (tick/inst)))
'time/zoned-date-time #'tick/zoned-date-time}})]
(fn [handler]
(cond-> handler
true (session/wrap-session {:store cookie-store
:cookie-name cookie-name
:cookie-attrs {:max-age cookie-default-max-age}})
true (cookies/wrap-cookies)))))
from kit.
Another option now that I think about it is to use Java's new date/time APIs instead... maybe that would be a sane default
from kit.
We could add Java default date/time API for cookies, but does seem like a fairly specific use case. It would definitely be good to add this in documentation though.
from kit.
@nikolap thanks a bunch! I was able to get it working with that info and example.
I'll leave this open since you guys are deciding on adding a default or just noting this in docs, but feel free to close it whenever.
from kit.
Added an example under cookie session documentation.
from kit.
Related Issues (20)
- Asset pipeline HOT 2
- Make it easy to discover kit-hato HOT 5
- Running migrations fails (HikariProxyConnection cannot be cast to class java.sql.PreparedStatement) HOT 5
- how to hot reload sql functions HOT 4
- build error with libpython-clj HOT 6
- how to run this hugsql snip HOT 2
- The Kit Clojurescript Docs uses an incorrect function to render to the DOM. HOT 1
- Add possibility to remove modules HOT 6
- New project with +mysql doesn't start HOT 1
- New project: "Error building classpath. Could not find artifact io.github.kit-clj:kit-undertow:jar:1.0.6 in central (https://repo1.maven.org/maven2/)" HOT 2
- creating template with deps-new does not create folders properly in windows HOT 14
- Expose query-fn for production use HOT 7
- could u support timbre log library HOT 10
- Consider version tagging repo HOT 4
- Help with plain websockets HOT 2
- update the docs to use integrant system as a parameter instead of via routes
- update nrepl component to suspend instead of halt so that the repl doesn't disconnect when the systme reloads HOT 2
- Can't create a new project HOT 1
- how to add multi db connections HOT 6
- how to log the sql executed HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from kit.