Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    vento007
    @vento007
    Hello... anyone know how to bind to the external interface and not localhost?
    vento007
    @vento007
    ahh found it.. traffic.SetVar("host", "0.0.0.0")
    Andrea Franz
    @gravityblast
    yes exactly, otherwise you can use the TRAFFIC_HOST env variable
    I'm sorry for the late reply but I wasn't here yesterday :)
    Mauro Cerbai
    @mcmaur
    Hi. I can't find example with json. And method neither. What should I do? I find only "WriteJSON" inside the ResponseWriter struct. So I try w.WriteJSON = json and the w.Render("");... Some help? please
    Andrea Franz
    @gravityblast
    hi @mcmaur
    do you mean something like this? https://gist.github.com/pilu/f06b55375ffb4e3a41e1
    Mauro Cerbai
    @mcmaur
    yes. Thank you. I thought there was to render something. I'm going to try it.
    Andrea Franz
    @gravityblast
    no problem . otherwise you can just use traffic.ResponseWriter as a normale http.ResponseWriter
    and you can do: json.NewEncoder(w).Encode(user)
    gianlucarossiinvece
    @gianlucarossiinvece
    Hi. I added a <a href="www.facebook.com/etc"; but it seems that this will call mysite/www.facebook.com. In order to have the same result I was trying to do a http.Redirect(w, r.Request, r.URL, http.StatusOk) over this routing rule: router.Get("/^www.";, function) but it's not working. Is it a valid routing regexp ?
    Andrea Franz
    @gravityblast
    @gianlucarossiinvece the value of the href should starts with http://.
    it’s not a problem with traffic, it a normal html/browser thing.
    Jer Hiebert
    @jhiebert
    Hello everyone! How do I deliver static content in production mode?
    Andrea Franz
    @gravityblast
    hi @ahhchuu I would use something else like nginx or an s3 bucket for static files in production
    David Satime Wallin
    @dvwallin
    Hi all. Got a quick question (or scenario perhaps): I have a small website written using traffic and im now looking to add an SSL cert to the site.
    I suppose I would need to add support for like https://golang.org/pkg/net/http/#Server.ListenAndServeTLS or something on my own?
    Andrea Franz
    @gravityblast
    hi @dvwallin
    I think you can just copy the Run() method that you can find in router.go
    and use ListenAndServeTLS instead of .ListenAndServe
    David Satime Wallin
    @dvwallin
    @pilu sounds easy enough. ill try that.
    David Satime Wallin
    @dvwallin
    @pilu it worked fine. sent a pullrequst (its tiny and simple) just for the sake of it
    thank you for the help
    Andrea Franz
    @gravityblast
    merged! thank you very much @dvwallin
    David Satime Wallin
    @dvwallin
    @pilu I dont know if i missed it but how would you suggest having a GET route with a wildcard in it in Traffic?
    Andrea Franz
    @gravityblast
    @dvwallin you can use router.Get("/:page_path*?", pageHandler), here an example:
    David Satime Wallin
    @dvwallin
    @pilu Question: Where, in the code, is the production-flag actually used? I tried to deploy a project with TRAFFIC_ENV=production and it then refuses to serve static files. All static files return 404 while the rest of the code works. Trying to figure out why
    Andrea Franz
    @gravityblast
    @dvwallin that's right. some middlewares are loaded only for development, and it's better to serve static files in a different way, maybe with nginx or something similar https://github.com/pilu/traffic/blob/master/router.go#L149
    David Satime Wallin
    @dvwallin
    aaah cool, thanks
    David Satime Wallin
    @dvwallin
    @pilu Mr Annoying is back with another question :-) To enable a new template function i figured i just need to call traffic.TemplateFunc("myNameToCallInTemplate", MyFunction) but that seems to be a wrong assumption.
    David Satime Wallin
    @dvwallin
    @pilu Never mind me. Im a dumb shit who forgets to look through all examples in repo. Sorry to bother you.
    Andrea Franz
    @gravityblast
    sorry @dvwallin I was on holiday, glad you already solved it :)
    ANDROID APK MOD
    @ANDROIDAPKMOD9_twitter
    hi