Skip to content

Latest commit

 

History

History
37 lines (26 loc) · 736 Bytes

README.md

File metadata and controls

37 lines (26 loc) · 736 Bytes

version

Package 'version' returns a HTTP request multiplexer with a "/version" pattern that return the application's version.

Usage

Implement the Versioner interface and pass it to the New method. Add the returned handler to your request multiplexer.

package main

import (
    "log"
    "net/http"

    "github.com/dhawal55/version"
)

type Version struct{}

func (v *Version) GetVersion() string {
    return "1.0"
}

func main() {
    mux := http.NewServeMux()
    //Add application handlers
    //mux.Handle("/users", userHandler)

    v := &Version{}
    versionMux := version.New(v)
    //Add versionMux to your application mux
    mux.Handle("/", versionMux)

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