Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Blog API built with Go and Gin

NotificationsYou must be signed in to change notification settings

aalug/blog-go

Repository files navigation

Built in Go 1.20

The app uses:

Getting started

  1. Clone the repository
  2. Go to the project's root directory
  3. Renameapp.env.sample toapp.env and replace the values
  4. Run in your terminal:
    • docker-compose up --build to run the containers
  5. Now everything should be ready and server running onSERVER_ADDRESS specified inapp.env

Testing

  1. Run the postgres container (docker-compose up)
  2. Run in your terminal:
    • make test to run all testsor
    • make test_coverage p={PATH} - to get the coverage in the HTML format - where{PATH} is the path to the target directory for which you want to generate test coverage. The{PATH} should be replaced with the actual path you want to use. For example./apior
    • use standardgo test commands (e.g.go test -v ./api)

API endpoints

Users

  • /users - handles POST requests to create users.
  • /users/login - handles POST requests to log in users.

Tokens/Session

  • /tokens/renew - handles POST requests to renew the access tokens.

Category

  • /category - handles POST requests to create categories
  • /category/{name} - handles DELETE requests to delete a category

Posts

  • /posts - handles POST requests to create posts.
  • /posts/{id} - handles DELETE requests to delete a post.
  • /posts/id/{id} and/posts/title/{slug} - handles GET requests to get post details.
  • /posts/all - handles GET requests to list all posts. Query params:page,page_size.
  • /posts/author - handles GET requests to list posts created by authorwith given name (that username or email contain given string).Query params:page,page_size,author.
  • /posts/category - handles GET requests to list posts from the given category.Query params:page,page_size,category_id.
  • /posts/tags - handles GET requests to list posts with given tags.Query params:page,page_size,tag_ids wheretag_ids iscomma-separated int format (e.g.&tag_ids=1,2,3).
  • /posts/{id} - handles PATCH requests to update the post.

Comments

  • /comments - handles POST requests to create a comment.
  • /comments/{id} - handles DELETE requests to delete a comment.
  • /comments/{id} - handles PATCH requests to update a comment.
  • /comments/{post_id} - handles GET requests to list comments of a post.Query params:page andpage_size.

Documentation

API

The API (HTTP gateway) documentation can be found atthis swaggerhub pageand (after running the server) athttp://localhost:8080/docs/

Database

The database's schema and intricate details can be found ondedicated webpage, which provides a comprehensive overviewof the data structure, tables, relationships, and other essentialinformation. To explore the database further, please visitthisdbdocs.io webpage.Password:bloggopassword

About

Blog API built with Go and Gin

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp