Questions tagged [mux]

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

331 questions
7
votes
1 answer

How to serve React

I have a simple React application I would like to serve from my Go server back end. I hear the process is similar to serving a static html file, but I just can't seem to get it to work. When I try to view the app on the browser it says "This page…
7
votes
1 answer

How to split GO Gorilla Mux routes in 2 separate files of the same package

I have separate file routes.go (package routes) where I store all my routes and handlers. But I want to split this file in 2 files. I want to rename my routes.go to main.go and create new additional file moduleX.go (package routes). How can I do…
Dzintars
  • 1,410
  • 21
  • 29
7
votes
4 answers

setup 404 NotFound handler on a gorilla mux router

Here is my code about a small demonstration webserver written with the Go language and the gorilla mux package : package main import ( "fmt" "github.com/gorilla/mux" "net/http" ) func handler(w http.ResponseWriter, r *http.Request) { …
Bussiere
  • 500
  • 13
  • 60
  • 119
7
votes
3 answers

Passing a query parameter to the Go HTTP request handler using the MUX package

I am trying to pass an additional parameter in the request I am trying to send to the Go server - websocket.create_connection("ws://:port/x/y?token="qwerty") The Go server implementation is as follows - func main() { err := config.Parse() …
psbits
  • 1,787
  • 5
  • 19
  • 34
6
votes
2 answers

What does it mean "invalid NAL unit size" for h.264 decoder?

I want to transmux a .mkv file to .mp4 using Libav but when I try to decode the video h.264 stream there is a malfunction in my code Invalid NAL unit size 21274662>141 Error splitting the input into NAL units The stream seems to contain AVCC…
user11903678
6
votes
4 answers

What is the symbol of the `mux` chip in C?

I was studying logic gates when I came to know that each logic gate was already defined in C. For example, for the AND logic gate, the symbol is &. For OR, it is |. But I could not find a symbol for the MUX chip. So, if there is a symbol for MUX,…
Box Box Box Box
  • 5,094
  • 10
  • 49
  • 67
5
votes
0 answers

Golang API Server won't receive Swagger API calls

My basic golang API server, created using mux package, is causing me some issues. I'm trying to use a provided SwaggerUI to commit calls to my localHost (at port 8080), and it doesn't seem to reach my server. At the same time, using the same Curl…
Avivoz
  • 51
  • 1
5
votes
1 answer

Passing arguments to mux handler function in golang

I'm trying to use mux and set some handlers. I have the following handler func homePage(w http.ResponseWriter, r *http.Request) { // Some code } func main() { router := mux.NewRouter().StrictSlash(true) router.HandleFunc("/",…
MohamedSaeed
  • 455
  • 1
  • 8
  • 11
5
votes
1 answer

Double slashes are not accepted even after using SkipClean

I have the following small program. It does not accept encoded double slashes (%2F%2F) even after using SkipClean while single encoded slash works fine. Could someone please suggest what is going wrong here? package main import ( "fmt" …
mandeep
  • 433
  • 8
  • 17
5
votes
1 answer

Return error when a handler reaches it max client limit

I have written a small wrapper function which use counting semaphore concept to limit number of connections to a particular handler (as this handler is resource consuming). Below is the code which achieve the same. func LimitNumClients(f…
Abhinav
  • 975
  • 4
  • 18
  • 35
5
votes
4 answers

Web process failed to bind to $PORT within 60 seconds of launch golang

I have developed a rest api using golang.I have pushed the repository to Heroku.I have also hosted a Mysql Server on the internet.The Go rest api connects to the Mysql Server and fetches and inserts data. The application on heroku was working fine…
freelancer86
  • 511
  • 2
  • 7
  • 20
5
votes
3 answers

Gorilla mux, best way to 'catch' response codes

I'm using Gorilla mux for all my routing. Now my app is working fine, I want to find a way to log all my response codes to -for example- statds. I have found this package: https://godoc.org/github.com/gorilla/handlers#LoggingHandler Which allows me…
Rogier Lommers
  • 2,263
  • 3
  • 24
  • 38
5
votes
2 answers

How do I split URLS in multiple Files using gorilla/mux?

My directory structure looks like this: myapp/ | +-- moduleX | | | +-- views.go | +-- start.go The app gets started with start.go and from there I configure all the routes and import the handlers from moduleX/views.go like this: package…
Subito
  • 227
  • 3
  • 12
4
votes
1 answer

go no required module provides package mux error

so I have the following code, package main import ( "github.com/gorilla/mux" ) func main() { router := mux.NewRouter() } when I do go run ., it gives the following error binapi.go:4:2: no required module provides package…
ProfMonkey07
  • 93
  • 1
  • 1
  • 7
4
votes
4 answers

How to use gorilla middleware handlers for all requests?

I want to use the handlers specified here for logging everything. This is what I have: r := mux.NewRouter() s := r.PathPrefix("/api/v1").Subrouter() s.HandleFunc("/abc", handler.GetAbc).Methods("GET") s.HandleFunc("/xyz",…
Lucas
  • 668
  • 1
  • 5
  • 17
1
2
3
22 23