Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Route Structure #31

Closed
ttola opened this issue Sep 6, 2014 · 1 comment
Closed

Route Structure #31

ttola opened this issue Sep 6, 2014 · 1 comment
Labels

Comments

@ttola
Copy link

ttola commented Sep 6, 2014

I am a little confused, how do you implement basic route of the form "/:title" without conflicting with "/"

@ttola ttola changed the title I am a little confused, how do you impletement basic route of the form I am a little confused, how do you implement basic route of the form "/:title" without conflicting with "/" Sep 6, 2014
@ttola ttola changed the title I am a little confused, how do you implement basic route of the form "/:title" without conflicting with "/" Route Structure Sep 6, 2014
@julienschmidt
Copy link
Owner

Exactly like the example in the README:

package main

import (
    "fmt"
    "github.com/julienschmidt/httprouter"
    "log"
    "net/http"
)

func Index(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
    fmt.Fprint(w, "Welcome!\n")
}

func Title(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
    fmt.Fprintf(w, "The Title is: %s\n", ps.ByName("title"))
}

func main() {
    router := httprouter.New()
    router.GET("/", Index)
    router.GET("/:title", Title)

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

similark pushed a commit to similarweb/httprouter that referenced this issue May 9, 2023
* Adding designdoc

Fixes kedacore/http-add-on#18

Signed-off-by: Aaron Schlesinger <aaron@ecomaz.net>

* Fixing links to components

Signed-off-by: Aaron Schlesinger <aaron@ecomaz.net>

* Adding architecture diagram and assets

Signed-off-by: Aaron Schlesinger <aaron@ecomaz.net>

* Fixing link to operator

Signed-off-by: Aaron Schlesinger <aaron@ecomaz.net>

* Adding a walkthrough document

Signed-off-by: Aaron Schlesinger <aaron@ecomaz.net>

* removing duplicate walkthrough section

Signed-off-by: Aaron Schlesinger <aaron@ecomaz.net>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants