/**************************************************************************************
 *
 *     Project:    kvmstoreserver
 *     File name:  versionInfo.go
 *     Version:    1.0.0
 *     Date:       2018-01-17
 *
 *     Autor:      Bogdanovic Theodor
 *     Contact:    t.bogdanovic@hotmail.com
 *
 *     License:    GPLv3
 *
 **************************************************************************************/
/**************************************************************************************
 * Copyright 2018 Bogdanovic Theodor
 *
 * This file is part of kvmstoreserver.
 *
 * kvmstoreserver is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * kvmstoreserver is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with kvmstoreserver.  If not, see <http://www.gnu.org/licenses/>.
 **************************************************************************************/
/**************************************************************************************
 *  Further explanations:  This source code is under the license specified by the
 *                         Autor above. Core components or other packages are still
 *                         in source code form, under the license specified by the
 *                         respective author.
 **************************************************************************************/

// Package versionInfo contains constants and functions which
// provide general program information
package versionInfo

import (
	"encoding/json"
	"essentials"
	"net/http"
)

// Staticlly hard coded base information about the kvmstoreserver
const (
	programName string = "kvmstoreserver"
	version     string = "1.0.0"
	buildTime   string = "2018-02-17__18:34.000"
	license     string = "GPLv3"
	autor       string = "Bogdanovic Theodor"
	contact     string = "t.bogdanovic@hotmail.com"
	infos       string = "HBU HF NDS, Diploma Project"
)

// VerInfoFinalHandler return a JSON document which contains essentail
// inforamtions about this program
func VerInfoFinalHandler(w http.ResponseWriter, r *http.Request) {
	essentials.InjectJSONTypeToHeader(w)

	innerAswerStruct := &struct {
		ProgramName string `json:"program_name,omitempty"`
		Version     string `json:"version,omitempty"`
		BuildTime   string `json:"build_time,omitempty"`
		License     string `json:"license,omitempty"`
		Autor       string `json:"autor,omitempty"`
		Contact     string `json:"contact,omitempty"`
		Infos       string `json:"infos,omitempty"`
	}{
		ProgramName: programName,
		Version:     version,
		BuildTime:   buildTime,
		License:     license,
		Autor:       autor,
		Contact:     contact,
		Infos:       infos,
	}

	jsonOutput, _ := json.MarshalIndent(innerAswerStruct, "", "\t")

	w.Write(jsonOutput)
}
