API ZeroHero

This is a simple example we did at an online event for community developers. A rEST API was created from scratch live 😍. Cool, huh ? 🇧🇷

All work can be found at:

github/zerohero zerohero.web.s3apis Youtube Live

This project is purely didactic and practical and was developed for the Bootcamp event, feel free to send a Pull Request 😍.

ZeroHero is an api that loads a base with superheroes and allows searches by biography, powerstats, connections , image, work and appearance.


mux := http.NewServeMux()
mux.HandleFunc("/", Service)

handler := cors.Default().Handler(mux)

s := &http.Server{
    Addr:           "0.0.0.0:8080",
    Handler:        handler,
}
log.Fatal(s.ListenAndServe())
.....
                        
crud_zerohero.go


$ curl -i -XGET -H "Content-Type:application/json" https://zerohero.s3apis.com/api/loki
{
    "response":"success",
    "id":"414",
    "uuid":"bbd34698-925d-4191-b60c-068926b0b9a2",
    "name":"loki",
    "powerstats":{
       "intelligence":"88",
       "strength":"63",
       "speed":"46",
       "durability":"85",
       "power":"100",
       "combat":"60"
    },
    "biography":{
       "full-name":"Loki Laufeyson",
       "aliases":[
          "God of Mischief",
          "Gem-Keeper",
          "Walter Lawson",
          "Lester",
          "Loren Olsen",
       ],
       "publisher":"Marvel Comics",
       "alignment":"bad"
    },
    "image":{
       "url":"https://www.superherodb.com/pictures2/portraits/10/100/928.jpg"
    }
 }