cgsdev0 / bash-stack

modern web framework in bash
https://bashsta.cc
MIT License
408 stars 7 forks source link

Dealing with json. #9

Closed the-man-with-a-golden-mind closed 2 months ago

the-man-with-a-golden-mind commented 2 months ago

Hello there. I am probably highly biased by ssr frameworks from node.js side but can we introduce "/api" folder which would work as "/pages" but serve json responses? Sometimes using non htmx approach and having more "typical" web framework would be a nice.

Best,

Michal

cgsdev0 commented 2 months ago

you can already serve json responses from the pages folder

example index.sh:

# headers
header Content-Type application/json
end_headers

cat <<-EOF
{
  "hello": "world"
}
EOF
the-man-with-a-golden-mind commented 2 months ago

Ok, still I would say that having separation between api and pages would be a good option for scaling the complexity of apps. But, is see your point :). If you don't have plans to add "/api" then I would just suggest to add that example into documentation.

cgsdev0 commented 2 months ago

i guess my question would be what's the functional difference between the two?

and also, what should happen if there is a name collision in the pages/ folder vs the api/ folder?

the-man-with-a-golden-mind commented 2 months ago

True. That would force more changes. I've read the implementation more carefully. I see that I can archive everything with existing solution. Thx. Closing this topic :)