Git Product home page Git Product logo
# me.yaml
name: Iacopo
from: Italy
based: Somewhere in the Cloud
role: Backend Developer
nick: Santiago
languages:
  - lang: Go
    affinity: 90
  - lang: PHP
    affinity: 80
  - lang: Rust
    affinity: WIP
databases:
  - MariaDB
  - PostgreSQL
  - Redis
miscs:
  - Docker
  - Kubernetes
  - Terraform
  - Nomad
hobbies:
  - Videogames
  - Gin Tonic
  - Coding
  - Repeat
package main

import (
	"encoding/json"
	"fmt"
	"io/ioutil"
	"log"
	"net/http"

	"gopkg.in/yaml.v2"
)

type Person struct {
	Name      string   `json:"name"      yaml:"name"`
	From      string   `json:"from"      yaml:"from"`
	Based     string   `json:"based"     yaml:"based"`
	Role      string   `json:"role"      yaml:"role"`
	Nick      string   `json:"nick"      yaml:"nick"`
	Langs     []Lang   `json:"languages" yaml:"languages"`
	Databases []string `json:"databases" yaml:"databases"`
	Miscs     []string `json:"miscs"     yaml:"miscs"`
	Hobbies   []string `json:"hobbies"   yaml:"hobbies"`
}

type Lang struct {
	Name     string `json:"lang"     yaml:"lang"`
	Affinity int    `json:"affinity" yaml:"affinity"`
}

func main() {

	var me Person

	yamlFile, err := ioutil.ReadFile("me.yaml")
	if err != nil {
		panic(err)
	}

	if err := yaml.Unmarshal(yamlFile, &me); err != nil {
		panic(err)
	}

	http.HandleFunc("/me", func(rw http.ResponseWriter, r *http.Request) {
		rw.Header().Set("Content-Type", "application/json")
		rw.WriteHeader(http.StatusOK)

		contentJson, err := json.Marshal(me)
		if err != nil {
			log.Fatal(err)
		}

		rw.Write([]byte(contentJson))
	})

	fmt.Println("Listening on :8080")

	log.Fatal(http.ListenAndServe(":8080", nil))
}

Iacopo Melani's Projects

berryhub icon berryhub

Hub domestico per tenere traccia della tua giornata

bips icon bips

Bitcoin Improvement Proposals

blog_os icon blog_os

Based on blog series https://os.phil-opp.com/

c-map icon c-map

A simple key-val array written in C

nginx-sshd icon nginx-sshd

Just a skeleton to use when in need of a running nginx server with ssh/sftp/scp access to its file structure.

tbp-cli icon tbp-cli

Cli tool to manage the-blockchain-pub

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.