Comments (7)
If I correctly understand the use case, what you are looking for is Genie.config.base_path
. Configure that in your script to match the extra segment(s) in the URL. Let me know if this is what you need.
from genie.jl.
If I correctly understand the use case, what you are looking for is
Genie.config.base_path
. Configure that in your script to match the extra segment(s) in the URL. Let me know if this is what you need.
Thanks for the response! That certainly looks like the setting I'm interested in.
I was curious how I might have missed that in the documentation. It looks like the search function can't find "base_path".
Also, the API docs don't seem to include the kwargs (and the "code" link doesn't seem to point to any code")
I thought I recalled some documentation (in a tutorial video?) about configuration, somewhere, but then wondered if it was in your very nice book: "Web Development with Julia and Genie"
I did find a config example in "Chapter 6: Deploying Genie Apps in Production". But base_path isn't shown in the examples.
I'll give it a try, and report back, when I get a chance.
Thanks!
from genie.jl.
The good news is that, with host = "0.0.0.0", etc., the request does seem to be getting to the node running the Genie server.
The bad news is that the Genie.config.base_path setting seems to have no effect, as Genie serves a 404, on that route.
julia> Genie.config.base_path
"/node/<hostname>/8000"
404 Not Found
Sorry, we can not find /node/<hostname>/8000
That's the exact same response as I get when I . . .
julia> Genie.config.base_path = ""
""
from genie.jl.
Looking at code like the following . . .
Line 395 in 7fe0529
. . . I wonder if this is actually the type of setting I'm looking for. That seems to be adding the base_path.
I would expect some code, somewhere, to actually remove the path from the front of the route, before passing to the router.
Maybe I simply need to make sure all routes have that prefix added to them, by setting a const variable and adding to each one.
Taking a look at . . .
https://genieframework.com/docs/genie/v5.11/tutorials/Advanced-Routing-Techniques.html
. . . I wonder if base_path will only take effect if I name the route.
I guess, either way, the route will get a name (but stable, if I assign it myself). But maybe the recommended pattern is to always build up routes via linkto().
e.g.
route(joinpath(linkto(:web_root), "sub_path")) do . . .
I guess I can learn by looking at some example web apps, maybe.
But I guess I'm still confused. Shouldn't the default up() command already be using the linkto command, incorporating the set config.base_path, whenever it resolves a route?
from genie.jl.
This function signature doesn't look right, to me. How can one assign to a default (. . . = basepath) which doesn't seem to be defined (except maybe globally, by accident)?
Line 392 in 7fe0529
I'm just wondering if that to_link() does end up being called directly, in most cases (to resolve routes). But it then it has no knowledge of base_path
.
Maybe that one is also supposed to default to the Genie.config.base_path, like this:
Line 446 in 7fe0529
?
Hmmm . . . I did not realize it was possible to assign to something undefined, in Julia.
julia> dumbfunc(arg1 = bob) = "$arg1 is dumb."
dumbfunc (generic function with 2 methods)
julia> bob
ERROR: UndefVarError: `bob` not defined
Perhaps that is allowed, to enable things to work if/when a symbol does come into scope.
Anyway, I don't see a basepath symbol in the Genie code, unless you bring the basepath function, under Configuration.jl, into scope.
from genie.jl.
I wonder if it wouldn't be better to handle the base_path
in this function (@AbhimanyuAryan ?):
Line 147 in 7fe0529
. . . or maybe pushed down into . . .
Lines 485 to 486 in 7fe0529
. . . rather than having it only handled/called when to_link
is called (apparently only intended to be used in html templates).
Because I can get my use case to work by . . .
julia> route(Genie.config.base_path, named=:web_root) do
"Hello Web Root"
end
But then . . .
julia> linkto(:web_root)
"/node/<hostname>/8000/node/<hostname>/8000"
. . . or is another way recommended? Can I use something like ":web_root" as a route? -or get_route().action() in a new route?
from genie.jl.
Related issue: GenieFramework/GenieFramework.jl#10
from genie.jl.
Related Issues (20)
- Loading Genie affects conversion of JSON3.Dict into Dict HOT 2
- Passing variables to `html` renderer yields key not found error HOT 4
- hot reload not possible once application hit the error, it require new bootstrap even in GENIE_ENV=dev HOT 4
- Genie.Logger.initialize_logging causes slow Arrow writes HOT 5
- Error reporting dumps sensitive information HOT 3
- Setting EARLYBIND "true" in Dockerfile causes port in use error HOT 3
- index-base transation missing. HOT 1
- Syntax error in first dashboard tutorial HOT 2
- [Bug] can't access own structure's properties in the reactive way HOT 11
- Typos in "your first dashboard" page in the website HOT 3
- Bug: Genie.Renderer.Html.html changes encoding when used with filepath HOT 2
- GC corrution in Genie[Session] HOT 1
- Applications compiled with Genie 5.23.x crashes (expected package `TimeZones [f269a46b]` to exist in the manifest) HOT 1
- Layout example does not work HOT 1
- Issues with the controller example from the docs HOT 4
- Multiple app modules no longer works HOT 6
- How to make the new Genie work behind nginx HOT 12
- Genie gives rise to a large number of GenieSession files via GenieSessionFileSession with enormous footprint >300GB HOT 26
- Dose Genie support handling multiple requests HOT 1
- Generator.setup_windows_bin_files() Fails with Julia from Windows App Store HOT 1
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 genie.jl.