Giter VIP home page Giter VIP logo

gcore's Introduction

#g-core

g-core is a super minimalist scaffolding for writing a REST API in Go.

Why should you care?

If you're not entirely sold on an entire Go framework, you're probably the type of person that wants to pick and choose your own middleware depending on what your project calls for. This scaffolding is as unopinionated as it can be in terms of middleware.

This is a starting point for those who don't want to write scaffolding over and over again, but also want the full flexibility of picking their own middleware.

User model/controller

You'll note that included is a user model + controller. This is simply to express a model / controller pattern that I have found works very well.

Getting started

Setting up

Before you start, make sure you have gom installed.

You will also need to set an environment variable named PORT to the port you would like gcore to run on.

After that, run these commands:

go get github.com/carrot/gcore
cd "$GOPATH/src/github.com/carrot/gcore/"
gom install
gom build

Now gcore should be ready to run, so just run:

./gcore

or if you have not set the PORT environment variable yet:

PORT=8001 ./gcore

Head over to http://localhost:$PORT/users/1 in a browser. If you get a 200 response, you're all set up.

Custom package name

Of course you don't want to use gcore as your project name, so we're going to have to do a little tweaking.

Run this command in the gcore directory:

grep -RI 'github.com/carrot/gcore' --exclude="README.md" .

Now go and replace all of the occurances of github.com/carrot/gcore with whatever your package name will be.

After you've finished that, you can actually move the library to the appropriate place in your gopath to match up with your new package.

You'll probably want to delete the README + git related files so you can start of fresh.

License

MIT

gcore's People

Contributors

brandonromano avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

jhliberty

gcore's Issues

Update response format

{
    "success": true,
    "status_code": 200,
    "status_text": "OK",
    "errors": [
        {
            "code": 1,
            "text": "Invalid email"
        }
    ],
    "content": {
        // ...
    }
}

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.