The Community Service is a Restful API where you can read create and delete posts.
If you want to run this Service you need
-
SQLite3 on your machine
-
Golang on your machine
-
go get "github.com/mattn/go-sqlite3"
-
go get "github.com/gorilla/mux"
-
go get "github.com/rs/xid"
-
go get "github.com/joho/godotenv"
-
go get "github.com/dgrijalva/jwt-go"
The rough architecture is based on this github repository https://github.com/kelvins/GoApiTutorial
The main file is for the initialization of the service.
Next there is the app.go file. This file handles the REST-Requests. For the Routing I used the gorilla mux library, because it is very lightweight. After a successfull request the request will be send to the models package. The models package consist of the json struct and a extra file for post and user
There is happening all the Database commands in sqlite3.
In The Service is one environment variable. This is the Path, where you want to safe your database. For example if you want to safe your database file in the root folder with the name "community.db", then you have to set an environment variable "DB_PATH" with the value "./community.db"
To test the REST-API there is a main_test.go file.
I also tried to implement the authorization middleware. Unfortunately i couldn't finish this feature because of missing time. You can see ma try in the autorization branch