Note: this documentation is created mainly for me if I want to run this project in the future. You can follow this document to run this project in your local too.
This project is a REST API to scrap the data from websites (different websites might still need a couple of adjustments to match the pattern of the data).
This project helps me to practice with:
- Develop real go project from scratch
- Goroutine and concurrency
- Channel
- Context
- Struct, and struct method
- Routing
- and more
- You must have Goose and SQLC installed on your machine.
- Run the migration by going to the sql/schema folder inside the project
cd sql/schemaand typegoose postgres postgres://postgres:@localhost:5432/rss-agg up(change the postgres URL with your own). - Build the project
go build && ./go-rss-aggregator
After you have successfully installed and built the project in order setup the dummy data, you must do the following:
- Open Postman or any app to access an API
- Access
http:localhost:8080/userswith the POST method and insert any name in the body, for example:{ "name": "Thomas Shelby" } - Copy the
api_keyafter the user was created. - Access
http://localhost:8080/feedwith POST method. Add theapi_keyto the HeadersAuthorization: ApiKey {api_key}. Insert these two data from the body (raw):
{
"name": "Lane's Blogs",
"url": "https://wagslane.dev/index.xml"
}
and
{
"name": "Boot Dev Blogs",
"url": "https://blog.boot.dev/index.xml"
}
After that, make sure to copy the id from the created feed.
5. Now visit http://localhost:8080/v1/feed-follows with the previous headers for authorization, and add the following to the body request:
{
feed_id: {your_feed_id}
}
You can add two of your recently created feeds.
6. Now you can rebuild the project and see the scrapper is running every minute.