Questions tagged [go-chi]

This tag should be used on questions related to the go-chi HTTP router.

go-chi is a lightweight router for building HTTP services, and especially REST API servers, in Go. It uses the context package introduced in Go 1.7 and aims at being fast, idiomatic and compatible with the standard Go net/http library.

68 questions
0
votes
0 answers

404 on appengine running go_app

I built small go app, which I run locally using the following // +build !appengine package main import ( "fmt" "net/http" "github.com/Test/test/server" ) func main() { r := server.Router() fmt.Println("Started Server") …
Soesah
  • 155
  • 2
  • 10
0
votes
1 answer

How to serve "/something" and "/something/" both on Golang(go-chi) router?

I am using go-chi router for my application but I am unable to serve "/something" and "/something/" both with one route, if I set my route as "/something" r := chi.NewRouter() r.Get("/something", func(writer http.ResponseWriter, request…
0xTanvir
  • 55
  • 1
  • 6
0
votes
1 answer

Go package naming

How do I reference project packages correctly? I have the following folder structure: /sbp /models.go /controllers.go /main.go In main.go I'd like to call my controller action from sbp.controllers. I can't seem to find a way to correctly…
Jiew Meng
  • 84,767
  • 185
  • 495
  • 805
-1
votes
2 answers

Cant add Contex Value with Chi from interface

i have data from interface, and i will add on context. from documentation is context.WithValue(r.Context(), key, val) i try to add 1 key and value is work, but can't work if more than 1. result := map[string]interface{}{} encoded, _…
-1
votes
1 answer

Go and Pointers in http middleware

I'm trying to log some data on my web server, so I created a loggingMiddleware that serves the next request and then logs the data, I thought this way I would have all the necessary data inside the r *http.Request pointer return…
Emil
  • 44
  • 5
-1
votes
1 answer

Is there a way to use the same request.Body in multiple handlers without manually write a lot of code or I need to change the way I'm doing this?

This amazing article here: https://www.alexedwards.net/blog/how-to-properly-parse-a-json-request-body explains very well how to write a Golang handler. I need to use two handlers, one after the other, only if the first one gives error. Like…
Fred Hors
  • 3,258
  • 3
  • 25
  • 71
-2
votes
2 answers

Unable to read cookies in Golang (router: chi)

I'm working on the REST API for a todolist app (no not from a tutorial) and i have successfully implemented authentication but one of my helper functions seems to be unable to read cookies that are clearly there, here is the function: // jwt is…
-3
votes
2 answers

Can't import a Go module

I'm learning Go ad I'm trying to build go file: package main import ( "github.com/go-chi/chi/v5" "github.com/go-chi/chi/v5/middleware" "net/http" ) func main() { r := chi.NewRouter() r.Use(middleware.Logger) r.Get("/",…
Vad Sim
  • 266
  • 8
  • 21
1 2 3 4
5