chilledoj / realworld-starter-kit

Golang + Gorilla mux Starter kit for new RealWorld framework implementations

Home Page:https://realworld.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

RealWorld Example App

Go + Gorilla codebase containing real world examples (CRUD, auth, advanced patterns, etc) that adheres to the RealWorld spec and API.

RealWorld

This codebase was created to demonstrate a fully fledged fullstack application built with Go + Gorilla including CRUD operations, authentication, routing, pagination, and more.

We've gone to great lengths to adhere to the Go community styleguides & best practices.

For more information on how to this works with other frontends/backends, head over to the RealWorld repo.

Other Go implementations

There are other GO implementations utilising the different web frameworks available to Golang developers.

Progress

API route status

  • Authentication (POST /api/users/login)
  • Registration (POST /api/users)
  • Get Current User (GET /api/user)
  • Update User (PUT /api/user)
  • Get Profile (GET/api/profiles/:username)
  • Follow user (POST /api/profiles/:username/follow)
  • Unfollow user (DELETE /api/profiles/:username/follow)
  • List Articles (GET /api/articles)
  • Feed Articles (GET /api/articles/feed)
  • Get Article (GET /api/articles/:slug)
  • Create Article (POST /api/articles)
  • Update Article (PUT /api/articles/:slug)
  • Delete Article (DELETE /api/articles/:slug)
  • Add Comments to an Article (POST /api/articles/:slug/comments)
  • Get Comments from an Article (GET /api/articles/:slug/comments)
  • Delete Comment (DELETE /api/articles/:slug/comments/:id)
  • Favourite Article (POST /api/articles/:slug/favorite)
  • Unfavourite Article (DELETE /api/articles/:slug/favorite)
  • Get Tags (GET /api/tags)

Other items

  • More Tests
  • Make simpler - maybe another branch to show simpler use of func (w http.ResponseWriter, r *http.Request) ?
  • Better/simpler error / response handling - just w.WriteHeader on error
  • alice/negroni chaining?
  • Optimise / Refactor / Data model Refining
  • Docker?
  • Vendor dependencies

How it works

See the wiki for more information.

Getting started

Installing and setting up Go

Getting the Project

go get github.com/chilledoj/realworld-starter-kit
cd $GOPATH/src/github.com/chilledoj/realworld-starter-kit

Installing dependencies

TODO: Vendor dependencies

go get ./..

Database (MYSQL)

Currently this codebase is utilising MYSQL as the database. Ensure you have created the database and tables (mysql_init.sql provided in models directory)

Building and Running

You can build using your own build flags, or use MAKE as there is a makefile provided.

make build

A run command is provided in the makefile which will first run the build step.

make run

N.B. The database URL (containing user+pass+host+port) can be set as an environment variable, passed as a flag to the executable or set in the config.ini file.

./bin/backend -dburl "root:password@/conduit?parseTime=true"
// or
DBURL=root:password@/conduit?parseTime=true ./bin/backend
// or -config config.ini
dburl=root:password@/conduit?parseTime=true

Additionally the IP host and ports are currently defaulted to run on ":8080", but can be passed in as ENV variables, command line flags or in the config.ini file: HOST or -host or host= and PORT or -port or port=.

N.B. See the flags package for more details on these are handled.

With Docker

Generate SSL self-signed certificate

openssl genrsa -out server.key 2048
openssl req -new -x509 -sha256 -key server.key -out server.crt -days 3650

Build & Run

docker-compose up --build

The api will be available at https://localhost:8080

Contributing

Raise an issue and/or Pull Request. Alternatively create your own better fork.

About

Golang + Gorilla mux Starter kit for new RealWorld framework implementations

https://realworld.io


Languages

Language:Go 95.0%Language:Shell 4.7%Language:Dockerfile 0.2%Language:Makefile 0.1%