Questions tagged [mux]

Package gorilla/mux implements a request router and dispatcher for matching incoming requests to their respective handler.

327 questions
91
votes
3 answers

FFMPEG mux video and audio (from another video) - mapping issue

I would like to place the audio from a video to another video without an audio (in one command): ffmpeg.exe -i video1_noAudio.mov -i video2_wAudio.mov -vcodec copy -acodec copy video1_audioFromVideo2.mov I guess "-map" is the correct way to do it…
Mark
  • 1,350
  • 1
  • 11
  • 20
65
votes
5 answers

Serving static content with a root URL with the Gorilla toolkit

I am attempting to use the Gorilla toolkit's mux package to route URLs in a Go web server. Using this question as a guide I have the following Go code: func main() { r := mux.NewRouter() r.Handle("/",…
jason
  • 1,157
  • 1
  • 7
  • 23
26
votes
1 answer

How to set http.ResponseWriter Content-Type header globally for all API endpoints?

I am new to Go and I'm building a simple API with it now: package main import ( "encoding/json" "fmt" "github.com/gorilla/mux" "github.com/gorilla/handlers" "log" "net/http" ) func main() { port := ":3000" var…
Zulhilmi Zainudin
  • 7,985
  • 8
  • 44
  • 79
23
votes
3 answers

Gorilla mux optional query values

I've been working on a Go project where gorilla/mux is used as the router. I need to be able to have query values associated with a route, but these values should be optional. That means that I'd like to catch both /articles/123 and…
stassinari
  • 383
  • 1
  • 3
  • 7
16
votes
1 answer

access post parameters in handler

I can access GET parameters using mux: import ( "github.com/gorilla/mux" ) func main(){ rtr := mux.NewRouter() rtr.HandleFunc("/logon", logonGet).Methods("GET") } func logonGet(w http.ResponseWriter, r *http.Request) { params :=…
Maxim Yefremov
  • 11,609
  • 21
  • 101
  • 153
16
votes
2 answers

Go and Gorilla Mux NotFoundHandler not working

I just can't get this NotFoundHandler to work. I'd like to serve a static file on every get request, given that it exists, otherwise serve index.html. Here's my simplified router at the moment: func fooHandler() http.Handler { fn := func(w…
QlliOlli
  • 607
  • 2
  • 12
  • 24
15
votes
2 answers

Go using mux Router - How to pass my DB to my handlers

At the moment, I try to create a small Web-Project using Go for data handling on the server. I try to pass my database-connection to my HandlerFunc(tions) but it does not work as expected. I am pretty new to golang, so maybe I did not understand…
Newbie
  • 1,544
  • 4
  • 27
  • 40
15
votes
3 answers

Nesting subrouters in Gorilla Mux

I've been using gorilla/mux for my routing needs. But I noticed one problem, when I nest multiple Subrouters it doesn't work. Here is the example: func main() { r := mux.NewRouter().StrictSlash(true) api := r.Path("/api").Subrouter() u…
Kortemy
  • 511
  • 4
  • 8
14
votes
1 answer

Should I use ServeMux or http directly in golang

I was wondering if I should create a new ServeMux and register it to the http.Server or should I invoke http.HandleFunc and http.Handler directly? I think the route with a ServeMux is better because http.HandleFunc obviously messes with the global…
Matt3o12
  • 3,732
  • 5
  • 26
  • 39
11
votes
1 answer

Chisel: how to implement a one-hot mux that is efficient?

I have a table, where each row of the table contains state (registers). There is logic that chooses one particular row. Only one row receives the "selected" signal. State from that chosen row is then accessed. Either a portion of the state is…
seanhalle
  • 835
  • 4
  • 23
11
votes
1 answer

When to use Golang's default MUX versus doing your own

I have seen a lot of posts talk about building your own MUX in Go, one of the many examples is here (http://thenewstack.io/building-a-web-server-in-go/). When should you use the default versus defining your own? The Go docs and none of the blog…
jordan2175
  • 740
  • 2
  • 8
  • 19
11
votes
2 answers

What's wrong with my DMux 4 way?

It's seemingly close to working, it just is messing up at line 7 apparently? /** * 4-way demultiplexor. * {a,b,c,d} = {in,0,0,0} if sel==00 * {0,in,0,0} if sel==01 * {0,0,in,0} if sel==10 * {0,0,0,in} if…
Doug Smith
  • 27,683
  • 54
  • 189
  • 363
10
votes
4 answers

Nested Gorilla Mux router does not work

Using code below, when I access /test2 it responds with 404 - not found. /test1 works correctly. Why is that? Is nesting not allowed despite the fact that routers implement http.Handler interface? package main import ( "fmt" "net/http" …
kars7e
  • 766
  • 1
  • 6
  • 19
9
votes
1 answer

GAE Golang Gorilla mux - 404 page not found

I've got some problems to use gorilla mux within GAE. When I try it, I've '404 page not found'. The rootHandler function is not called ( no traces generated) Below is part of my code, any ideas? thk in advance ... func init() { r :=…
rlasjunies
  • 309
  • 1
  • 5
  • 10
8
votes
4 answers

golang mux, routing wildcard & custom func match

I'm using the mux package which seems to work quite well except that it doesn't seem to support complex routes or at least I don't get it how it does. I have several routes as following: router :=…
themihai
  • 6,579
  • 11
  • 32
  • 53
1
2 3
21 22