summaryrefslogtreecommitdiff
path: root/backend/main.go
blob: 7b66e00ff5e517ce6a24331d858ddce6f02f90b8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package main

import "fmt"
import "net/http"

func RecipeList(w http.ResponseWriter, r *http.Request) {
	if r.Method == "GET" {
		fmt.Printf("Return all recipe names...\n")
	} else if r.Method == "POST" {
	} else if r.Method == "DELETE" {
	}
}

func HandleRecipe(w http.ResponseWriter, r *http.Request) {
	name := r.URL.Path[len("/recipes/"):]
	if r.Method == "GET" {
		fmt.Printf("Return recipe \"%s\"...\n", name)
	} else if r.Method == "POST" {
		fmt.Printf("Create recipe \"%s\"...\n", name)
	} else if r.Method == "DELETE" {
		fmt.Printf("Delete recipe \"%s\"...\n", name)
	}
}

func main() {
	http.HandleFunc("/recipes", RecipeList)
	http.HandleFunc("/recipes/", HandleRecipe)
	http.ListenAndServe(":8888", nil)
}