Comments (8)
Could you explain the issue with more details?
from grip.
Now to set routing for static files
class DemoController < Grip::Controllers::Http
def getHtml(context : Context) : Context
context
.send_file("./public/index.html")
end
end
class Application < Grip::Application
def initialize(@port : Int32)
super(environment: "development", serve_static: true)
scope "/" do
get "/html", DemoController, as: :getHtml # This works well.
scope "/foo" do
get "/html", DemoController, as: :getHtml
# Request to host/foo/html => ok
# Request to other static files => 404 Not Found
# In the url http://localhost/foo/static/js/main.2ee217bf.js, /foo is not expected.
end
end
end
...
end
from grip.
is this what you are looking for?
from grip.
is this what you are looking for?
I have set the static file directory and assigned serve_static true.
It can only handle request to root path, right?
from grip.
I mean the url path.
from grip.
is this what you are looking for?
I have set the static file directory and assigned serve_static true. It can only handle request to root path, right?
Depends on how you structure your directories, for example:
public/
images/
cat.jpeg
pages/
cat.html
index.html
You will be able to access cat.jpeg
by /images/cat.jpeg
and cat.html
by /pages/cat.html
.
from grip.
I mean the prefix part of the path unrelated to the file structure.
I'm seeking for a portable solution.
For example, to access the same files
app.Static("/foo", "./public") => GET http://localhost/foo/index.html
app.Static("/foo/bar", "./public") => GET http://localhost/foo/bar/index.html
app.Static("/foo/bar/baz", "./public") => GET http://localhost/foo/bar/baz/index.html
from grip.
I mean the prefix part of the path unrelated to the file structure. I'm seeking for a portable solution.
For example, to access the same files
app.Static("/foo", "./public") => GET http://localhost/foo/index.html app.Static("/foo/bar", "./public") => GET http://localhost/foo/bar/index.html app.Static("/foo/bar/baz", "./public") => GET http://localhost/foo/bar/baz/index.html
It could be an interesting feature, I will leave this open.
from grip.
Related Issues (20)
- Undefined method 'final' for OpenSSL::Digest HOT 1
- Grip::Pipes::Log show/print only HTTP status 200 requests HOT 5
- Rendering HTML does not have a default encoding HOT 8
- TechEmpower benchmark is broken HOT 1
- Built in static asset server HOT 5
- Custom error handling and compile error HOT 1
- Grip seems to be outdated in crystalshards.org HOT 1
- JSON error bug HOT 5
- Better json format HOT 1
- Route with override would cause instantiating new instance of controller for each request
- Feature request: File upload/download HOT 4
- Index syntax HOT 3
- Do you accept contributions? HOT 1
- Clarify documentation about exception handling HOT 1
- Handle arbitrary exceptions HOT 3
- To handle CORS preflight OPTIONS requests HOT 3
- Wrong behavoir of serve_static on Windows HOT 2
- SHA1 Alternatives HOT 1
- Error: execution of command failed with exit status 1 HOT 3
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 grip.