modulepackage
0.0.0-20240901192650-18441fb1a4e5
Repository: https://github.com/gnualex/go-api.git
Documentation: pkg.go.dev
# README
Sample Go REST API
Overview
This repository contains a sample REST API written in Go.
Getting Started
Prerequisites
Installation
-
Clone the repository:
git clone https://github.com/GNUalex/go-api.git cd go-api
-
Install dependencies:
go mod tidy
-
Build the project:
go build -o app
Running the API
To run the API locally, use the following command:
go run .
The API will be accessible at http://localhost:8080
.
Docker
To run the API in a Docker container:
Run the Docker container:
docker run --rm -ti -v $PWD:/app -w /app -p 8080:8080 golang:alpine go run .
The API will be accessible at http://localhost:8080
.
API Endpoints
Here are some example endpoints provided by the API:
- GET
/posts
: Retrieve all posts. - GET
/post/{slug}
: Retrieve a single post by slug.
Request and Response Examples
GET /posts
Response:
[
{
"id": 1,
"title": "Sample blog post 1",
"slug": "sample-blog-post-1",
"publishedAt": "2024-09-01 16:26:03.227426841 +0200 CEST m=+4.718829503",
"author": "GNUalex",
"content": "Proin tristique sagittis nisl, sit amet ultricies nulla vehicula nec. Ut imperdiet lacus eu porttitor feugiat. Aenean ipsum risus, rhoncus ac tempor at, rhoncus vitae dui. Aliquam erat volutpat. Morbi non vulputate ipsum."
}
]
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is licensed under the GNU GENERAL PUBLIC LICENSE - see the LICENSE file for details.
Acknowledgments
- Go Official Documentation - Excellent resource for learning Go
# Packages
No description provided by the author
No description provided by the author
No description provided by the author