Comments (6)
actually, this seems to happen for sub directories as well, which means I'm misunderstanding something.
box := packr.NewBox("./public")
http.Handle("/", http.FileServer(box))
fmt.Println("serving docs at http://localhost:8080")
fmt.Println("hit ctrl-C to cancel")
go browser.OpenURL("http://localhost:8080")
log.Fatal(http.ListenAndServe(":8080", nil))
^^ This will serve up what's in ./public if the folder exists, but if I remove the folder, it gives me 404s.
from packr.
note that this is after running packr, while having a packer file that looks like this:
func init() {
packr.PackJSONBytes("./public", "index.html", "\"SGkgTWFyayE=\"")
}
from packr.
Looks like the problem actually has to do with how http.FileServer
handles index.html
files:
http.Handle("/", http.FileServer(http.Dir("/tmp")))
As a special case, the returned file server redirects any request ending in "/index.html" to the same path, without the final "index.html".
If I throw any other file in the box it works just as expected. It's literally only index.html
files.
from packr.
oh man, that is crazy town. Thanks for figuring this out :)
from packr.
lol. Tell me about it! I had to dig deep to figure how to make it work. They’re doing some really strange things in the http package.
from packr.
If you want an http.FileServer
-like construct with ability to turn off special handling of index.html
files, it's quite easy to make your own. You can see an example of one I've created at https://godoc.org/github.com/shurcooL/httpgzip#FileServer.
from packr.
Related Issues (20)
- What parameters need to be changed in the source code of the Full HD application?
- can not get a right import path in go.mod env HOT 1
- Restore entire directory tree HOT 1
- How can I pack a binary and run it from a box?
- <Deleted>
- Unable to install packr on MAC
- Packr v2 not working with Docker HOT 2
- Security vulnerability in required package HOT 2
- Packr2 is running normally, but uses in the GitHub Action environment, the following error occurs: HOT 2
- Please release for GOOS=linux & GOARCH=ppc64le HOT 1
- Vulnerability due to usage of github.com/coreos:etcd:3.3.10
- packr2 does not respect go build's module path
- Source tree and go module versioning HOT 4
- This broke our CI pipeline for several projects :'( HOT 2
- Master branch issue with v2 references HOT 1
- packr build not working after migrating to packr v2 HOT 2
- How do i pack exe into my golang program and run the exe when golang program
- How do i pack my go file with icon and some go build argument while i use packr command
- use packr2 in command line HOT 1
- packr was deprecated and will be archived. please use `embed` instead. 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 packr.