package main

import (
	"log"
	"net/http"
	"strconv"
	"time"

	"github.com/sony/sonyflake"
)

func handler(w http.ResponseWriter, r *http.Request) {
	id, _ := flake.NextID()
	w.Header().Set("expire", expire)
	w.Header().Set("xsollauid", strconv.Itoa(int(id)))
}

var flake *sonyflake.Sonyflake
var expire string

func init() {
	flake = sonyflake.NewSonyflake(sonyflake.Settings{StartTime: time.Date(2018, 1, 1, 0, 0, 0, 0, time.UTC)})
	// +10 years
	expire = time.Now().Add(10 * 366 * 24 * time.Hour).Format("Mon, 02-Jan-2006 15:04:05 MST")
}
func main() {
	http.HandleFunc("/", handler)
	log.Fatal(http.ListenAndServe(":8080", nil))
}
