Package gorilla/mux implements a request router and dispatcher for matching incoming requests to their respective handler.
Questions tagged [mux]
331 questions
2
votes
0 answers
send errors to sentry with Golang and Mux
I’m a bit new to Golang, and trying to integrate Sentry with Golang and Gorilla Mux
In the main.go, I added:
func init() {
raven.SetDSN("https://xxxx@sentry.io/xxxxx")
}
As stated in the doc
Then in my route definition, I…

Juliatzin
- 18,455
- 40
- 166
- 325
2
votes
1 answer
MIME type (“text/plain”) mismatch (X-Content-Type-Options: nosniff)
I was using golang net/http funcions and had no errors, but I needed custom URL so I implemented gorilla/mux router and now getting errors like this:
The resource from “http://localhost:8080/styles.css” was blocked due to MIME type (“text/plain”)…

batijo
- 41
- 1
- 8
2
votes
2 answers
Url escaped parameter not resolving properly
I have generated a simple gorilla/mux API using swagger.
For my single endpoint /v1/abc/{arg} I am passing an argument.
Therefore a request like: http://localhost:9090/v1/abc/hello simply echos the argument for now.
The following function handles…

cocoseis
- 1,443
- 1
- 13
- 35
2
votes
2 answers
How do I write a common method in golang to insert record in any of the mysql tables
I'm creating a rest api in golang and making a POST request into a table.
For this I've created a struct. Basically the vars in struct is same as the columns in table named users.
and written a function to make a POST request. And the code is…

Shambhu
- 181
- 6
- 16
2
votes
0 answers
Gorilla/mux middleware not being hit
I am on go version go1.10.4 linux/amd64
I am registering middleware, but they don't seem to be hit.
package main
import (
"encoding/json"
"fmt"
"github.com/dgrijalva/jwt-go"
"github.com/gorilla/context"
…

Alexander Mills
- 90,741
- 139
- 482
- 817
2
votes
1 answer
Best Practice to pass *gorm.db instance in a custom handler in go http
I am creating a custom web handler to handle my routes in an web application.
The handler is
type CustomHandler struct{
Db *gorm.DB
}
Then a receiver function:
func (h CustomHandler) Index() http.Handler {
return http.handlerFunc(w…

ABEL KURUVILLA
- 31
- 1
- 6
2
votes
0 answers
mux Router type for returned anonymous function
I have this:
type RegisterHandler struct{}
func (h RegisterHandler) Mount(router *mux.Router, v interface{}) {
router.HandleFunc("/register", h.MakeRegisterNewUser(v))
}
func (h RegisterHandler) MakeRegisterNewUser(v interface{})…
user7898461
2
votes
1 answer
Unable to set query parameters manually for a rest api (using mux)
I am implementing a Rest api using mux. After validating some parameters, I am trying to fill the missing parameters with some default values which I process later by the method that handles the request, however, I noticed that setting query…

zakaria amine
- 3,412
- 2
- 20
- 35
2
votes
0 answers
How to write PathPrefixStripRegex in Traefik?
I have a Docker containers that are running on the ECS Cluster on AWS. I am using Traefik to route certain routes to services. For this I am using DockerLabels option in CloudFormation and one of them is traefik.frontend.rule and…

daniyel
- 652
- 10
- 28
2
votes
2 answers
Failure to connect to localhost:3000 from web application
I'm working on some boilerplate code to get a VueJS frontend working with a Go-powered backend (using gorilla/mux for a router):
Currently, I seem to have everything working for the most part. I'm serving a static HTML file via Go and rendering Vue…

MisutoWolf
- 1,133
- 1
- 18
- 33
2
votes
2 answers
How can I send a url-encoded url as a parameter to mux?
I have this code
func main() {
router := mux.NewRouter()
router.HandleFunc("/", rootHandler)
router.HandleFunc("/xyz/{url}", urlHandler)
http.Handle("/", router)
log.Fatal(http.ListenAndServe(":8080", nil))
}
With this url:…

jim
- 101
- 1
- 5
2
votes
1 answer
Mux return if variable not defined?
I want to handle the situation where a param wasn't defined.
import (
// ...
"github.com/gorilla/mux"
)
func main() {
router := mux.NewRouter()
router.HandleFunc("/connect", Connect).Methods("POST")
…

Philip Kirkbride
- 21,381
- 38
- 125
- 225
2
votes
2 answers
Golang JSON config for routes
I have been trying to setup a JSON config file to setup dynamic routes for my application. The idea is that I will be able to setup my own URL structure depending on who is using the service. I have a struct that takes in JSON and that works fine. I…

Paul A.T. Wilson
- 854
- 2
- 9
- 18
2
votes
1 answer
Extreme pipelining in VHDL?
I was wondering which of the following designs is faster, i.e., can operate at a higher Fmax:
-- Pipelined
if crd_h = scan_end_h(vt)-1 then
rst_h <= '1';
end if;
if crd_v = scan_end_v(vt) then
rst_v <= '1';
end if;
…

Ran
- 31
- 3
2
votes
2 answers
Chisel3. Functional Module Mux4
I'm learning Chisel following the documentation on Github
Thus far, everything worked flawlessly. But i'm stuck at chapter 13, "Functional Module Creation"
I can't get the code to work. I created all my .scala classes in a copy of the…

mtosch
- 351
- 4
- 18