Coder Social home page Coder Social logo

go-playground / pure Goto Github PK

View Code? Open in Web Editor NEW
148.0 9.0 14.0 110 KB

:non-potable_water: Is a lightweight HTTP router that sticks to the std "net/http" implementation

License: MIT License

Go 99.83% Makefile 0.17%
http-router native-http context

pure's People

Contributors

deankarn avatar tectiv3 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pure's Issues

Can middleware share info?

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.

static file syntax

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?

/user/100/ match p.Get("/user/:id"

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

_examples/ vs examples/

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.