An API for a blog written in GO with ElasticSearch.
- Clone the repository
git clone https://github.com/afifialaa/blog.git
- Change directory
cd blog
- Install dependencies
go get
func SetEnv() {
fmt.Println("Setting env")
os.Setenv("CLOUD_MONGO", "<YOUR_CONNECTION_STRING>")
os.Setenv("PORT", "8000")
}
func InitApp() {
fmt.Println("Initializing app")
ES, err := elasticsearch.NewDefaultClient()
if err != nil {
panic("Client failed")
}
fmt.Println(ES.Ping())
}
Server will be running on port 8000
Method | Route | description |
---|---|---|
GET | /blog | Fetches all articles |
POST | /blog | Creates new article |
DELETE | /blog | Deletes an article |
PUT | /blog | Updates an article |
Method | Route | Description |
---|---|---|
GET | /comment | Fetches comments of an article |
POST | /comment | Creates new comment |
DELETE | /comment | Deletes a comment |
PUT | /comment | Update a comment |
- User authentication