Giter VIP home page Giter VIP logo

gorouter's Introduction

Hi there 👋

why ?

I develop out of love ❤️ to code and desire to constantly improve myself as a software developer and architect. I believe that open source projects are the future, allowing other people to contribute and improve technology by covering more edge cases on a wider spectrum of a problems.

In modern times where technology drives our lives and big IT giants spit lots of software out trying to gain monopoly in every area, open source developers are more than needed to redirect the traffic back to people and focus on world's needs rather than tracking and collecting information for money.

who am I ?

I am a Senior Software Engineer at Autopilot, a graduate of Computer Science at the Faculty of Electronics, Wrocław University of Science and Technology where I did both my Bachelor and Masters degrees. Full stack software developer with lot of experience. Knowing the highest programming method and cutting edge technologies. I am constantly striving to learn new technologies and looking for ways to better myself in this rapidly changing industry. Beside working full time I am doing open source projects and develop my own applications. I am dedicated to my craft and I am proud of my code. I am trying to write beautiful, efficient code to a high standard, in a timely and scalable way that improves the code-base of products in meaningful ways.

my work

I am interested in DDD, CQRS, ES, gRPC, developing tools to help software work better in production, solving most common problems without overthinking it. Simple is the best but performance matters. Software I develop is often a result of the need to build solutions for problems I encounter at work. I like to explore different ways of problem solving and trying different methods to address any issues.

If you follow the same principles you are more then welcome to have a look at my work. If anything (and I hope more than one), seems interesting or useful for you, don't hesitate to contribute!

gorouter's People

Contributors

bohyunjung avatar ceriath avatar dependabot[bot] avatar fossabot avatar frytyler avatar mar1n3r0 avatar vardius 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

gorouter's Issues

Refactor tests

Tests could use some refactor, there are multiple case scenario that repeats just for different settings etc.

Wildcard node matching

Consider following routes:

  1. /:name/x
  2. /:name/y

And requests:

  1. /test/x
  2. /test/y
  3. /test/z

Should do:

  • request 1. should match route 1
  • request 2. should match route 2
  • request 3. should match no route

What happens:

  • request 1. matches route 1
  • request 2. matches no route
  • request 3. matches no route

TODO:

  • add test for following case
  • confirm if problem exist
  • fix it if exist

Static path middleware is applied to all wildcard paths

    router := gorouter.New()
    router.GET("/hello/{name}", http.HandlerFunc(Hello))

    router.USE("GET", "/hello/Joe", someMiddleware)

    log.Fatal(http.ListenAndServe(":8080", router))

Given the example above middleware for path /hello/Joe will be applied to wildcard route /hello/{name} as the path of middleware matches node's path, resulting in middleware being invoked for all requests matching node's pattern.

  • /hello/Joe
  • /hello/Jerry

etc.

Fix Wiki small code example typos

I am trying out the examples and spotted a few typos which prevent some of them running as described. Please share Wiki access so I can fix them as I run the tests.

I am new to Go and would appreciate some help on the following:

import (
        "github.com/vardius/gorouter/v4/context"
)

main.go:10:9: cannot find package "github.com/vardius/gorouter/v4/context"

How does this thing work with version name-spacing ?

General middleware execution order

Following the topic here: #22 (review)

We can take a more general stance and discuss middleware execution order in general.
What we know so far is that the core logic behind generating the tree has a default pattern which it strives to maintain throughout it's whole life cycle:

Sort Nodes in order [statics, regexps, wildcards]

If we abstract away the phases of the gorouter we can conceptualize the following:

  • tree generation of nodes with routes - based on router.GET calls
  • applying middleware and creating orphaned nodes without routes when there is no match with the existing tree nodes - based on router.USE calls
  • processing request path two more phases:
  • first checking if the path matches nodes with routes to allow access to middleware layer at all
  • applying middleware

The concept is quite clear and neat until the last phase of applying middleware. All phases are going through the same Match loops reusing the same structure and order with some custom processing for orphaned nodes.

Where things get unclear is in the phase of applying middleware. Because it goes through the default ordered structure rather than respecting the user defined middleware order
it contradicts with one of the basic core features of a router namely user defined middleware order of execution:

Mux supports the addition of middlewares to a Router, which are executed in the order they are added if a match is found, including its subrouters.

Although initially discussed in the light of the isolated case concerning orphaned nodes only this seems to be of critical importance to the overall predictability of middleware execution order as the default ordering mechanism will always aim to process statics before regexps before wildcards even if the user defined order is different and more importantly unique each time(not a repeating pattern).

Incompatible tag in go.mod

When pulling through github.com/vardius/gorouter as a dependency, my go.mod file has the +incompatible tag:

module example.com

go 1.12

require github.com/vardius/gorouter v3.0.7-0.20190205101248-eab65e0a6301+incompatible

I think this is because the gorouter repository isn't following the module path conventions for v2+ repositories.

Context params missing

Tested in all middleware scenarios.

func Hello(w http.ResponseWriter, r *http.Request) {
	params, _ := context.Parameters(r.Context())
	fmt.Fprintf(w, "params: %v\n", params)
	fmt.Fprintf(w, "hello, %s!\n", params.Value("name"))
}

URL mock:

http://localhost:8080/hello/test

output:

params: []
hello, !

Context package imported as suggested with:

export GO111MODULE=on
go get -u -v github.com/vardius/gorouter/v4/context

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.