This is a CRM Backend Project that provides a set of APIs for managing customer data. This is a final project for Go Language (Golang) course at Udacity.
-
Clone the repository:
git clone https://github.com/gkj/golang.git
-
Change to the project directory:
cd golang
-
Install the dependencies:
go mod download
-
Run the service:
go run main.go
To use the APIs, you can perform CURL requests to the following endpoints:
Endpoint: /customers
Method: GET
Description: Retrieves all customers.
curl --location 'http://localhost:3000/customers' \
--data ''
Endpoint: /customers/{id}
Method: GET
Description: Retrieves a single customer by their ID.
curl --location 'http://localhost:3000/customers/1' \
--data ''
Endpoint: /customers
Method: POST
Description: Creates a new customer.
curl --location 'http://localhost:3000/customers' \
--header 'Content-Type: application/json' \
--data-raw '{
"id": 4,
"name": "Gilang",
"role": "User",
"email": "[email protected]",
"phone": "098763454321"
}'
Endpoint: /customers/{id}
Method: PUT
Description: Updates an existing customer by their ID.
curl --location --request PUT 'http://localhost:3000/customers/3' \
--header 'Content-Type: application/json' \
--data-raw '{
"id": 3,
"name": "Gilang Kusuma",
"role": "User",
"email": "[email protected]",
"phone": "098763454321"
}'
Endpoint: /customers/{id}
Method: DELETE
Description: Deletes a customer by their ID.
curl --location --request DELETE 'http://localhost:3000/customers/3' \
--data ''