Package gorilla/mux implements a request router and dispatcher for matching incoming requests to their respective handler.
Questions tagged [mux]
331 questions
-1
votes
2 answers
Function handler GoLang using Standard Library
I have an endpoint like events/{id} and a handler for it. How can I get {id} without using Gorilla/Mux. What are the GoLang in-built alternatives that can achieve this? Need to do this without gorilla/Mux or other third-party libraries. I know this…

sxp
- 193
- 1
- 1
- 11
-1
votes
1 answer
Example JSON response with Golang
I am trying to build an API with golang. To get started I am just trying to send some json data when I visit http://localhost:8085/search but all I am viewing in the browser is null.
I got this example from a Medium post
package main
import (
…

Ryan Sam
- 2,858
- 4
- 19
- 30
-1
votes
2 answers
How to pass a nested struct into an argument
I'm trying to create a struct for my API routes. I have two structs: Queries and Route. Then I have a slice of my routes that is made based of my type Route.
After I create my Routes, I then create a new router and iterate over the range of Routes…
user11217893
-1
votes
1 answer
GoLang/Mux syntax question: if ID, Ok = mux.Vars(r)["ID"]; !ok
I am very new to Golang and I am reading someone's code for an API using gorilla/mux and I came across this block of code.
func heroGet(w http.ResponseWriter, r *http.Request) {
var ID string
var Ok bool
if ID, Ok = mux.Vars(r)["ID"];…

lee.edward01
- 453
- 1
- 6
- 16
-1
votes
1 answer
How to set up Mongo DB in Go for a rest service that allows for unit testing?
I am setting up a rest service in go using MongoDB and mux routers. I am running into issues on how to best set this up to allow for unit/integration testing in a separate database.
I have tried setting up the database in the Init() function but…

jmacnc
- 157
- 2
- 7
- 19
-1
votes
1 answer
How to set a value in mux.Vars(request)
I want to set a value in mux.Vars() with MatcherFunc return true, then handlerFun can access to read.
But panic assignment to entry in nil map when mux.Vars(request)["key"] = "value"
How can I set a value:
domainRouter :=…

qi.feng
- 1
-1
votes
1 answer
Golang getting a 404 whilst server is running
I am trying to run a basic web app, following a tutorial, using Golang and the routing package Gorilla/mux. The server is running fine but it refuses to find the index.html file regardless of what I put in the browser, always returning a 404.
Here…

JamWill
- 134
- 3
- 21
-1
votes
1 answer
How to set up a route to serve reactjs app?
I'm trying to set up a route to serve my reactjs application.
I have my index.html and bundle.js in the public folder
/public/index.html
/public/bundle.js
I'm using go as my backend API, and also to serve my reactjs app.
I created a subroute for my…

Blankman
- 259,732
- 324
- 769
- 1,199
-1
votes
1 answer
writing verilog module codes for up/down counter, 4to1 mux, pulsegen
I'm fairly new to the world of creating verilog modules and I have to create a 4to1 mux, pulse generator, up/down counter, and a hex-to-7segment display. These are all later put into a toplevel module.
I tried to create the 7segement and pulse…

Erica L
- 1
- 3
-1
votes
2 answers
feedback on mux in verilog
I am preforming a feedback mux calculation using verilog. But however the system does not response (giving X) to one of input which is B (the input controlled by the mux). Can helping me pointing out where is the error and how to fix it.
Here are…

Jack93
- 21
- 1
- 4
- 13
-1
votes
1 answer
VHDL structural architecture and clk'event
A if condition in VHDL can be implemented using a MUX. But I want my MUX's output to vary when there is a rising edge for the clock.
I really wanted to give clock and clk'event as the select line for my MUX.
signal a:std_logic;
process(clk)
a <=…
-1
votes
1 answer
Verilog Arithmetic Equation System Exercise
I am new to Verilog and I found some interesting exercises to work on but there is this one exercise I am stuck on, can anyone help me ???
The exercise:
Implement an arithmetic equation system which, when given some
values at its inputs, will give…

Techflow
- 1
- 1
- 3
-2
votes
1 answer
hot to convert ioutil.ReadAll into json in golang
I'm trying to convert a response into json in golang.
func receive(w http.ResponseWriter, r *http.Request) {
reqBody, _ := ioutil.ReadAll(r.Body)
json.NewEncoder(w).Encode(string(reqBody))
println(string(reqBody))
func handleR() {
…

Fabian
- 11
- 3
-2
votes
1 answer
json.NewDecoder(r.Body).Decode(&admin) returns empty struct
I know there are a lots of people that has run into the same issue but still here I am. I'm pretty sure my code is correct and still the resulting struct is empty.
Function :
func PostAdminHandler(w http.ResponseWriter, r *http.Request) {
…

raphael.oester
- 124
- 11
-2
votes
1 answer
http.Handler value in argument to r.Handle: missing method ServeHTTP error
I was trying to build basic web API using gorilla mux in Go. Here is my code. Please help me understand how some interfaces are working here.
func main() {
r := mux.NewRouter()
r.Handle("/", http.FileServer(http.Dir("./views/")))
…

jagdish
- 9
- 1
- 1