Files
api_web_manager/web/web.go

40 lines
967 B
Go

package web
import (
"api_manager/web/api"
"api_manager/web/manager"
"api_manager/web/render"
"fmt"
"net"
"net/http"
)
func Server() {
l, err := net.Listen("tcp", ":8090")
if err == nil {
fmt.Println("Listening on port 8090")
}
http.Serve(l, http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
switch r.URL.Path {
case "/":
main_page(w,r);
case "/mgr/add":
manager.Add_api(w,r)
case "/mgr/show":
manager.Render_apis(w,r)
case "/api/":
api.Get_api(w,r)
default:
fmt.Fprint(w,"Not Found")
return
}
}))
}
// wellcoming main web page
func main_page(w http.ResponseWriter, req *http.Request) {
templ := map[string]string{"welcome_message": "hello world! this is api server with easy web menagment","template_title":"main page"}
fmt.Fprint(w, render.Put_vars_to_template(render.Template_of_part("main"), templ))
}