GoAsWebServer/web/server.go
2022-08-03 22:49:52 +02:00

34 lines
671 B
Go

package web
import (
"net/http"
"github.com/gorilla/mux"
)
func NewServer() *Server {
server := &Server{
Router: mux.NewRouter(),
}
server.HandleFunc("/todos", server.todos).Methods("GET")
server.HandleFunc("/todos", WithAuth(server.todoCreate)).Methods("POST")
server.HandleFunc("/todos", WithAuth(server.todoDelete)).Methods("DELETE")
return server
}
type Server struct {
*mux.Router
}
func (server *Server) todos(w http.ResponseWriter, r *http.Request) {
// TODO get
}
func (server *Server) todoCreate(w http.ResponseWriter, r *http.Request) {
// TODO get
}
func (server *Server) todoDelete(w http.ResponseWriter, r *http.Request) {
// TODO get
}