controller

package
v0.0.0-...-73e22f4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 4, 2020 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var GetCache = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
	data, found := helper.GetCache("emp_data")
	if found {
		fmt.Println(data)
		w.WriteHeader(http.StatusOK)
		fmt.Fprintf(w, "successfully! data has been saved in cache")
	} else {
		w.WriteHeader(http.StatusBadRequest)
		fmt.Fprintf(w, "Error! Not found key into cache")
		return
	}
})
View Source
var SaveCache = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
	var emp helper.Emp
	decoder := json.NewDecoder(r.Body)
	err := decoder.Decode(&emp)

	if err != nil {
		w.WriteHeader(http.StatusBadRequest)
		fmt.Fprintf(w, "Error saving cache")
		return
	}
	helper.SetCache("emp_data", emp)

	w.WriteHeader(http.StatusOK)
	fmt.Fprintf(w, "successfully! data has been saved in cache")
})

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL