Skip to content

juanpipeline/star-wars-characters-api

Repository files navigation

   _____ _          __          __            
  / ____| |         \ \        / /            
 | (___ | |_ __ _ _ _\ \  /\  / /_ _ _ __ ___ 
  \___ \| __/ _` | '__\ \/  \/ / _` | '__/ __|
  ____) | || (_| | |   \  /\  / (_| | |  \__ \
 |_____/ \__\__,_|_|    \/  \/ \__,_|_|  |___/

   _____ _                          _                
  / ____| |                        | |               
 | |    | |__   __ _ _ __ __ _  ___| |_ ___ _ __ ___ 
 | |    | '_ \ / _` | '__/ _` |/ __| __/ _ \ '__/ __|
 | |____| | | | (_| | | | (_| | (__| ||  __/ |  \__ \
  \_____|_| |_|\__,_|_|  \__,_|\___|\__\___|_|  |___/
                                                     
                                                   
           _____ _____ 
     /\   |  __ \_   _|
    /  \  | |__) || |  
   / /\ \ |  ___/ | |  
  / ____ \| |    _| |_ 
 /_/    \_\_|   |_____|
                                                                                   

Let's get started

Database configuration

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

Env variables

Then you have to set env variables (If you are using MacOS run source local.zsh):

  • DB_HOST
  • DB_USER
  • DB_PASSWORD
  • DB_NAME

Don't you want to clone the repo?

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

Do you want to clone the repo?

Run app installing

go install github.com/juanpipeline/star-wars-characters-api
$HOME/go/bin/star-wars-characters-api

Run app using Docker

docker build -t goapp .
docker run -it -p 8080:8080 --env-file="local.env" goapp

Run app using binary

./star-wars-characters-api

Interactive documentation with swagger

Go to the url: http://localhost:8080/swagger/index.html#/default/get_characters

Examples

Now you can create Yoda into your database:

alt text

Then you can search Yoda by his name:

alt text

You can even change his hair color

alt text

References

About

A simple APIRest to Star Wars character using Golang (gin,gorm)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published