There is an answered question which will help you understand what exactly I want to say.
How does the function passed to http.HandleFunc get access to http.ResponseWriter and http.Request?
There are many built-in Go functions where the function parameters get assigned this way. I want to use that coding style in my daily coding life.
I want to write a similar function/method which will get its parameter values from somewhere just like http.Handlefunc's w and r.
func (s SchoolStruct) GetSchoolDetails(name string){
// here the parameter "name" should get assigned exactly like http.HandleFunc()'s "w" and "r".
}
type MyHandlerFunc func(string)/type MyHandler interface { GetSchoolDetails(string) }. Then write a router that invokes the correct handler with the parsed input. Then write a server that takes some input parses that into the valid handler input, and then passes that parsed input to the router. Example snippet you can find innet/httppackage (Go is open sourced).GetXyz(string)using the net/http handler pattern seems very much misguided. The wrong tool for the job. You might want to rethink and redisgn.GetSchoolDetailsto be triggered? Some event listener? Or maybe a job scheduler? In thenet/httppackage thewandrare prepared by the server and passed through the router to the handler. Which handler is executed depends on the incoming request...