gorilla Questions

2

Solved

I would like to have some of my query parameters be optional. As for now, I have r.HandleFunc("/user", userByValueHandler). Queries( "username", "{username}", "email", "{email}", ). Methods(...
Krys asked 12/4, 2017 at 21:28

2

I saw an article written by Mat Ryer about how you can use a server type and http handlers of the type that are wrappers for func(http.ResponseWriter, *http.Request) I see this as a more elegant w...
Bedspread asked 8/12, 2018 at 1:12

2

Solved

What is the proper syntax to create a simple "match anything" handler? mux.NewRouter().StrictSlash(true).Path("/").... The above code seems to strictly match / and /foo won't get matched
Hamer asked 14/4, 2017 at 18:31

4

I cannot get value from session this way, it is nil: session := initSession(r) valWithOutType := session.Values[key] Full code: package main import ( "fmt" "github.com/gorilla/mu...
Affricative asked 30/1, 2015 at 14:17

2

Solved

I want to create global err handler to send it by email. package main import ( "github.com/gorilla/mux" "log" "net/http" ) func main() { rtr := mux.NewRouter() ...
Rebus asked 26/2, 2015 at 14:58

3

So I just started learning the Go programming language and have spent hours on end looking at examples, references and so forth. As most of you would agree there is no better way to learn a languag...
Dardar asked 10/4, 2016 at 9:33

1

Solved

I noticed that there are two ways to specify a path in the gorilla/mux router: r.PathPrefix("/api").Handler(APIHandler) And: r.Handle("/api", APIHandler) What is the difference? Also, I don'...
Joe asked 3/7, 2018 at 19:58

3

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....
Coastal asked 10/2, 2017 at 14:48

3

Solved

I am using Go and the Gorilla web toolkit's mux and handler packages to build a complex application, part of which requires a http server. Gorilla's mux and handler packages work wonderfully and I ...
Rici asked 18/7, 2016 at 18:42

2

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: fu...
Abelmosk asked 26/10, 2014 at 13:16

5

Solved

TLDR: gorilla/mux used to not offer the possibility to set URL Vars. Now it does, that's why the second-most upvoted answer was the right answer for a long time. Original question to follow: Here'...
Jellaba asked 23/12, 2015 at 11:57

1

Solved

I have a go web app which serves static HTML/JS/CSS files plus has some API endpoints. I noticed that my HTML/JS/CSS are not being cached on the browser. E.g., every time I reload a page, they are ...
Chondro asked 20/2, 2018 at 0:46

1

I have made a app where I need to serve the same files to multiple routes because the front end is a React app. I have been using gorilla mux for the router. The file structure is as follows: main...
Hydrolytic asked 5/2, 2018 at 20:1

1

Solved

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 additiona...
Diglot asked 4/2, 2018 at 19:49

2

Solved

I'm running on HTTPS (port 10443) and use subroutes: mainRoute := mux.NewRouter() mainRoute.StrictSlash(true) mainRoute.Handle("/", http.RedirectHandler("/static/", 302)) mainRoute.PathPrefix("/st...
Caulfield asked 12/7, 2015 at 18:26

1

Solved

I have a mux and 4 different routes. a.Router = mux.NewRouter() a.Router.HandleFunc("/1/query/{query}", a.sigQuery).Methods("GET") a.Router.HandleFunc("/1/sis", a.rGet).Methods("GET") a.Router....
Piselli asked 6/7, 2017 at 16:44

1

Solved

I have studied the Godoc of the gorilla/websocket package. In the Godoc it is clearly stated that Concurrency Connections support one concurrent reader and one concurrent writer. Applicatio...
Tapley asked 5/4, 2017 at 8:4

2

Solved

I am developing a golang application and I am using Gorilla Mux and i want to redirect HTTP requests to HTTPS here is what i have so far package main import ( "net/http" "github.com/gorilla/m...
Skilken asked 12/1, 2017 at 15:29

1

In gorilla/sessions, func NewCookieStore(keyPairs ...[]byte) *CookieStore is a used to create a new CookieStore. But I don't actually know what is a secret key (or an authentication key). The desc...
Gilkey asked 26/7, 2016 at 13:24

2

Solved

I see that Go itself has a package net/http, which is adequate at providing everything you need to get your own REST APIs up and running. However, there are a variety of frameworks; the most popula...
Mcquade asked 8/7, 2016 at 10:25

1

Solved

I'm writing a chat program with Golang and Gorilla's Websocket toolkit. I'm wondering if there is a way to run a function whenever a user disconnects or a ping/pong message fails. I need this to r...
Ress asked 8/6, 2016 at 7:57

2

Solved

I am working on a simple todo app in go. I have determined that all the pages except a user's list of todos can safely be a static html page. * Login form * new account form * index page that talk...
Stilu asked 29/6, 2014 at 21:25

2

Solved

Theres a websocket running in my localhost on ws://localhost:8080/ws I need go lang code that can create a websocket client and connect to this server. My Google-Fu skills failed to teach me a si...
Questionless asked 23/9, 2015 at 17:21

1

Solved

Here's my setup: I'm building a service (using Negroni and Gorilla) with user login, where upon login, the user gets a session cookie which the server uses to authorize protected endpoints. One of ...
Anna asked 29/3, 2015 at 0:27

1

I'm reasonably new to golang and am trying to do work out the best way to do this idiomatically. I have an array of routes I am statically defining and passing to gorilla/mux. I am wrapping each h...
Goodygoody asked 26/6, 2015 at 12:15

© 2022 - 2024 — McMap. All rights reserved.