Skip to content

Latest commit

 

History

History
41 lines (35 loc) · 1.8 KB

README.md

File metadata and controls

41 lines (35 loc) · 1.8 KB

Shields.io Go SDK for creating an endpoint.

Build Status Coverage Status Go.Dev reference Go Report Card Release Downloads Chat Community

$ go get -u clevergo.tech/shields
import (
	"encoding/json"
	"net/http"

	"clevergo.tech/shields"
)

func handler(w http.ResponseWriter, req *http.Request) {
    badge := shields.New("label", "message")
    badge.LabelColor = shields.ColorBlue
    err := badge.ParseRequest(req)
    if err != nil {
        http.Error(w, err.Error(), http.StatusInternalServerError)
        return
    }

    data, err := json.Marshal(badge)
    if err != nil {
        http.Error(w, err.Error(), http.StatusInternalServerError)
        return
    }

    w.Header().Set("Content-Type", "application/json")
    w.Write(data)
}