package httpapi

import (
	"example.com/shop/internal/order"
	"fmt"
	"net/http"
)

func NewHandler() http.Handler {
	return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
		total, err := (order.Order{Items: 2}).Total(500)
		if err != nil {
			http.Error(w, "invalid order", http.StatusBadRequest)
			return
		}
		fmt.Fprintf(w, "total=%d\n", total)
	})
}
