go-playground / pure Goto Github PK
View Code? Open in Web Editor NEW:non-potable_water: Is a lightweight HTTP router that sticks to the std "net/http" implementation
License: MIT License
:non-potable_water: Is a lightweight HTTP router that sticks to the std "net/http" implementation
License: MIT License
Hi Dean,
How would a middleware function (e.g. JWT auth) share data (a JWT struct) to all the remaining middleware functions in the chain? RequestVars
seems to be read-only.
I have a root folder /static with subfolders for js, css, etc. The code:
p.Get("/static/*", http.FileServer(http.Dir("static/")).ServeHTTP)
...gives me a 404 in the browser even though the paths in the browser are correct (e.g. http://localhost:5000/js/plugins/prism.js)
I would like the URL in the browser to remain http://localhost:5000/js/plugins/prism.js
What should the code look like?
package main
import (
"net/http"
"github.com/go-playground/pure/v5"
mw "github.com/go-playground/pure/v5/_examples/middleware/logging-recovery"
)
func main() {
p := pure.New()
p.Use(mw.LoggingAndRecovery(true))
p.Get("/user/:id", helloWorld)
http.ListenAndServe(":3007", p.Serve())
}
func helloWorld(w http.ResponseWriter, r *http.Request) {
w.Write([]byte("Hello World"))
}
http://localhost:3007/user/ 404
http://localhost:3007/user/100 right
http://localhost:3007/user/100/ expect 404 but result same as /user/100
Some your other packages (in other repos) try to import using examples/
path instead of _examples/
- this breaks things like go install all
which process all packages, including ones in examples directories.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.