Git Product home page Git Product logo

golang-goji-sample's Introduction

Golang Goji Sample

Sample Web Application based on https://github.com/elcct/defaultproject

Dependencies

Default Project requires Go, MySQL and few other tools installed.

Project structure

/controllers

All your controllers that serve defined routes.

/helpers

Helper functions.

/models

You database models.

/public

It has all your static files mapped to /assets/* path except robots.txt and favicon.ico that map to /.

/system

Core functions and structs.

/views

Your views using standard Go template system.

server.go

This file starts your web application and also contains routes definition.

golang-goji-sample's People

Contributors

ajiyoshi-vg avatar haruyama avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

golang-goji-sample's Issues

Please use gopkg.in/gorp.v1

I see that you are importing gorp from github.com/go-gorp/gorp.
This is the unstable "bleeding edge" version. We are working on breaking changes, it is likely that your program will fail to compile unless you update your code to reflect the changes.

Please use gopkg.in/gorp.v1 as import path, it provides the last stable gorp v1 release and will not break (unless a breaking change is required to fix a security issue).

When the changes to the master branch are complete, v2 will be released. See go-gorp/gorp#270 for more information.
Thanks.

Session doesn't clear for subroutes

  1. In server.go, I created this routes
goji.Get("/apitest", application.Route(controller, "apitest"))
goji.Get("/api/test", application.Route(controller, "apitest"))

Both of them just prints out the value of session.Values["UserId"]

  1. I log in, so that session.Values["UserId"] has a value.
  2. I visit both /apitest and /api/test, and they print out value of session.Values["UserId"] fine
  3. Then I log out, so that session.Values["UserId"] is set to nil
  4. I visit both /apitest and /api/test, /apitest will now print out nil; api/test still print the value of session.Values["UserId"]

What did I do wrong here?

Clearing gorilla session

Hi,

I must be missing something, but just wondering how are you clearing the gorilla session in these sample project? As per their doc http://www.gorillatoolkit.org/pkg/sessions

Important Note: If you aren't using gorilla/mux, you need to wrap your handlers with context.ClearHandler as or else you will leak memory! An easy way to do this is to wrap the top-level mux when calling http.ListenAndServe: "

So aren't we supposed to clear them somehow?
Thanks

Invalid Csrf Token

When siging up and later signing in all I get is "Invalid Csrf Token". I'm probably overlooking something but the subtle.ConstantTimeCompare(x, y) in "isValidToken" never throws a 1 for me.
Like I said, I'm probably overlooking something. Thanks.

Missing ClearHandler?

Since you are using Gorilla Session, wouldn't you need the following middleware at the end of the middleware use chain in server.go

goji.Use(context.ClearHandler)

This uses the ClearHandler from gorilla.context to not leak memory.

See http://www.gorillatoolkit.org/pkg/sessions (search for phrase "Important Note")
I could of course be missing something. Thanks for an excellent example for how to use Goji. I've been learning immensely from using it. Thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.