Comments (4)
var theme
is not thread-safe.
using {.threadvar.}
.
from mofuw.
I don't understand, what you mean by that.
from mofuw.
The theme variable is shared by all server threads.
from mofuw.
So putting the theme variable inside of /
route, allows the program to compile.
What if I need to share the theme
variable with multiple routes?
import os, asyncfile
import mofuw
import "./theme" as Theme
routes:
serve("public")
get "/":
var theme = Theme(
defaultName: "default",
extension: "html",
directory: parentDir(currentSourcePath()) / "views"
)
theme.init()
var data = await theme.defaultTheme.readAll()
mofuwResp(HTTP200, "text/html", data)
# mofuwOK("Hello")
echo "Starting CMS Server"
newServeCtx(
port = 8000,
handler = mofuwHandler
).serve()
from mofuw.
Related Issues (20)
- Official Tech Empower Bench with misconfigured mofuw HOT 3
- high priority TODO HOT 1
- --gc:boehm problem
- clean up all HOT 1
- support HTTP/2.0 HOT 2
- SSL problem HOT 1
- mig asyncdispatch2 or make own custom dispatcher ? HOT 2
- Error: type mismatch: got <nil> but expected 'string' HOT 1
- type mismatch: got <port: int literal(8080), handler: proc (ctx: MofuwCtx): Future[system.void]{.locks: <unknown>.}> HOT 2
- CLOSE_WAIT problem
- using accept4 for better performance.
- `mofuw` creates wrong error message when accessing shared memory HOT 2
- routing thread-safe
- static file serving failed
- using MAPLE instead of asyncdispatch HOT 1
- deprecated timeout
- Served files are loaded directly into memory, not streamed HOT 7
- binary file read issue
- `helloworld` compiles error
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 mofuw.