|
|
|
|
|
|
|
|
Username string |
|
|
Username string |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// -------------------- HTML Template -------------------- |
|
|
func Index(w http.ResponseWriter, r *http.Request) { |
|
|
func Index(w http.ResponseWriter, r *http.Request) { |
|
|
if html, err := template.ParseFiles(filepath.Join("views", "index.html")); err != nil { |
|
|
if html, err := template.ParseFiles(filepath.Join("views", "index.html")); err != nil { |
|
|
http.Error(w, err.Error(), http.StatusInternalServerError) |
|
|
http.Error(w, err.Error(), http.StatusInternalServerError) |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// -------------------- JSON Template -------------------- |
|
|
type Response struct { |
|
|
type Response struct { |
|
|
Code int |
|
|
Code int |
|
|
Text string |
|
|
Text string |
|
|
|
|
|
|
|
|
rex.Use(livereload.Middleware) |
|
|
rex.Use(livereload.Middleware) |
|
|
rex.Get("/", Index) |
|
|
rex.Get("/", Index) |
|
|
|
|
|
|
|
|
apis := rex.Group("/v1/") |
|
|
|
|
|
apis.Use(JSON) |
|
|
|
|
|
apis.Get("/", fetch) |
|
|
|
|
|
apis.Post("/", create) |
|
|
|
|
|
apis.Put("/", update) |
|
|
|
|
|
apis.Delete("/", remove) |
|
|
|
|
|
|
|
|
api := rex.Group("/v1/") |
|
|
|
|
|
api.Use(JSON) |
|
|
|
|
|
api.Get("/", fetch) |
|
|
|
|
|
api.Post("/", create) |
|
|
|
|
|
api.Put("/", update) |
|
|
|
|
|
api.Delete("/", remove) |
|
|
|
|
|
|
|
|
rex.Run() |
|
|
rex.Run() |
|
|
} |
|
|
} |