25 questions
0 votes
1 answer
83 views
(why) Is it necessary to path parameters via request context?
I'm working on a simple toy API in Golang using httprouter and trying to write tests for my endpoints. One of my endpoints is a "show movie" endpoint with a path like /v1/movies/:id . For ...
1 vote
1 answer
146 views
Running Embed Angular app with Golang (EmbedFS )
I'm trying to run an angular compiled application in Golang with EmbedFS but no success. I'm new with Golang so I have troubles to make it working. My Golang app structure is -- project | - cmd ...
2 votes
1 answer
3k views
go http 1.22 subrouter
So I want to get rid of one more dependency (gorilla/mux) and use the std http.ServeMux with it's new routing patterns. The problem is, that gorilla/mux had this concept of a subrouter, which could ...
3 votes
1 answer
2k views
Set different middleware for a subroute in go-chi
I have a proxy server that can be deactivated by config, with mustBeSecure. I want this proxy to act different in a certain subdomain: "/application/health", allowing it always insecure. All ...
1 vote
1 answer
122 views
httprouter panic: path must begin with '/' in path 'GET'
I am moving my handler from net/http / mux to httprouter and my tests are failing. I am doing a request to a server running in a separate go routine. httprouter is complaining that the path must start ...
2 votes
1 answer
1k views
go chi treating sub route path as URL param
i am creating a base router and adding few middlewares and health check route as below baseRouter := chi.NewRouter() baseRouter.Use(middleware.Logger) baseRouter.Use(core.CorsHandler) baseRouter.Get(&...
2 votes
2 answers
982 views
How to nest routers in Go julienschmidt/httprouter?
I want to expose the following URLs from my service: GET /api/foo GET /api/bar I also want to structure it as a router nested inside another. The toplevel router will match all requests to /api and ...
1 vote
1 answer
934 views
panic: http: multiple registrations for / (root path)
I am trying to start two http server on different ports, but unable to use the same pattern: handlerFunc1 := http.HandlerFunc(hello1) http.Handle("/", handlerFunc1) server1 := &http....
0 votes
2 answers
928 views
How to handl these routes in go httprouter: /hello/:name and /hello/b/c?
httprouter does not allow this and panics when start. httprouter :panic: wildcard route ':name' conflicts with existing children in path '/hello/:name'. In my understanding, "/hello/:name"...
0 votes
1 answer
636 views
404 page not found when trying to use Gqlgen with julienschmidt/httprouter
Below is the code I run the issue is that I get 404 page not found instead of the graphql playground page Is it possible to work with httprouter with gqlgen or do I need to go back to chi or mux I ...
3 votes
1 answer
5k views
Context value is nil when getting it with unexported struct key in Go HTTP handlers
Any help here is appreciated! I'm sure that I'm missing something really basic. The problem I have is I am trying to get a value out of context in a demo web application, and I'm receiving the error: ...
0 votes
1 answer
855 views
httprouter forward to another handler with parameters & url update
I'm thinking about the following scenario: Suppose I want have handler X in which I have made some calculations but now want to forward to another handler Y before returning the request. It would be ...
0 votes
1 answer
364 views
passing named parameters to index template while using httprouter golang package
I just learnt how to use the httprouter go package and read many documents about it but failed to use the :name style of passing paramenters toe templates when it comes to the index page template. ex. ...
1 vote
1 answer
922 views
Using TLS/SSL Client Authentication for specific hosts
How can I use TLS/SSL Client Authentication for specific Hosts when using a reverse proxy like httprouter by julienschmidt? I could set a Client Certificate in a global matter with http....
0 votes
1 answer
11k views
how to parse multiple parameters in url in GoLang?
I am new in Go. So please provide an example with your answer. I am using julienschmidt/httprouter. I am able to parse one parameter with this but how can I parse multiple parameters using this or any ...