_____ _ __ __
/ ____| | \ \ / /
| (___ | |_ __ _ _ _\ \ /\ / /_ _ _ __ ___
\___ \| __/ _` | '__\ \/ \/ / _` | '__/ __|
____) | || (_| | | \ /\ / (_| | | \__ \
|_____/ \__\__,_|_| \/ \/ \__,_|_| |___/
_____ _ _
/ ____| | | |
| | | |__ __ _ _ __ __ _ ___| |_ ___ _ __ ___
| | | '_ \ / _` | '__/ _` |/ __| __/ _ \ '__/ __|
| |____| | | | (_| | | | (_| | (__| || __/ | \__ \
\_____|_| |_|\__,_|_| \__,_|\___|\__\___|_| |___/
_____ _____
/\ | __ \_ _|
/ \ | |__) || |
/ /\ \ | ___/ | |
/ ____ \| | _| |_
/_/ \_\_| |_____|
You need to have a postgres database to run this api. If you don't have a server, you can use Docker.
docker run --name postgres-db -e POSTGRES_PASSWORD=anakin1234 -e POSTGRES_DB=characters -e POSTGRES_USER=anakin -p 5432:5432 postgres
Then you have to set env variables (If you are using MacOS run source local.zsh):
- DB_HOST
- DB_USER
- DB_PASSWORD
- DB_NAME
Get the Package
go get -v github.com/juanpipeline/star-wars-characters-api
Then run the exec
$HOME/go/bin/star-wars-characters-api
$HOME is the path where golang is installed
go install github.com/juanpipeline/star-wars-characters-api
$HOME/go/bin/star-wars-characters-api
docker build -t goapp .
docker run -it -p 8080:8080 --env-file="local.env" goapp
./star-wars-characters-api
Go to the url: http://localhost:8080/swagger/index.html#/default/get_characters
Now you can create Yoda into your database:
Then you can search Yoda by his name:
You can even change his hair color