package main

import (
    "fmt"
    "html"
    "log"
    "net/http"
)

type item struct {
    node string
    value int
}

type Node struct {
    head item
    left item
    right item
}

func split(x int) (a, b, c int){
    a = 1
    b = 2
    c = 3
    return
}

func getChildren(a Node) (b, c item) {
    b = a.left
    c = a.right
    return
}

func main() {
    http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
        fmt.Fprintf(w, "Hello, %q", html.EscapeString(r.URL.Path))
    })
    
    http.HandleFunc("/hi", func(w http.ResponseWriter, r *http.Request){
        fmt.Fprintf(w, "Hi")
    })

    log.Fatal(http.ListenAndServe(":8081", nil))

}
package main

import (
    "fmt"
    "log"
    "net/http"
)

type article struct {
    title string
    datePosted int
    desc string
    content string
}

func homePage(w http.ResponseWriter, r *http.Request){
    fmt.Fprintf(w, "Welcome to the HomePage!")
    fmt.Println("Endpoint Hit: homePage")
}

func returnArticle(w http.ResponseWriter, r *http.Request) {
    fmt.Fprintf(w, "returns a specific article")
    fmt.Println("Endpoint Hit: returnArticle")
}

func returnAllArticles(w http.ResponseWriter, r *http.Request){
    fmt.Fprintf(w, "All Articles")
    fmt.Println("Endpoint Hit: returnAllArticles")
}

func addArticle(w http.ResponseWriter, r *http.Request){
    fmt.Fprintf(w, "Adds an article to list of articles")
    fmt.Println("Endpoint Hit: addArticle")
}

func delArticle(w http.ResponseWriter, r *http.Request){
    fmt.Fprintf(w, "deletes a specific article")
    fmt.Println("Endpoint Hit: delArticle")
}

func handleRequests() {
    http.HandleFunc("/", homePage)
    http.HandleFunc("/all", returnAllArticles)
    http.HandleFunc("/single", returnArticle)
    http.HandleFunc("/delete", delArticle)
    http.HandleFunc("/add", addArticle)
    log.Fatal(http.ListenAndServe(":8081", nil))
}

func main() {
    handleRequests()
}
Structure of a basic REST API
Structure of a basic REST API
