func PutItemJSONHandler(w http.ResponseWriter, req *http.Request) {
	if bbpd_runinfo.BBPDAbortIfClosed(w) {
		return
	}
	start := time.Now()
	if req.Method != "POST" {
		e := "put_item_route.PutItemJSONHandler:method only supports POST"
		log.Printf(e)
		http.Error(w, e, http.StatusBadRequest)
		return
	}
	pathElts := strings.Split(req.URL.Path, "/")
	if len(pathElts) != 2 {
		e := "put_item_route.PutItemJSONHandler:cannot parse path. try /put-item, call as POST"
		log.Printf(e)
		http.Error(w, e, http.StatusBadRequest)
		return
	}

	bodybytes, read_err := ioutil.ReadAll(req.Body)
	req.Body.Close()
	if read_err != nil && read_err != io.EOF {
		e := fmt.Sprintf("put_item_route.PutItemJSONHandler err reading req body: %s", read_err.Error())
		log.Printf(e)
		http.Error(w, e, http.StatusInternalServerError)
		return
	}

	p_json := put.NewPutItemJSON()
	um_err := json.Unmarshal(bodybytes, p_json)

	if um_err != nil {
		e := fmt.Sprintf("put_item_route.PutItemJSONHandler unmarshal err on %s to PutExpected: %s", string(bodybytes), um_err.Error())
		log.Printf(e)
		http.Error(w, e, http.StatusInternalServerError)
		return
	}

	p, perr := p_json.ToPutItem()
	if perr != nil {
		e := fmt.Sprintf("put_item_route.PutItemJSONHandler cannot convert PutItemJSON to PutItem:%s", perr.Error())
		log.Printf(e)
		http.Error(w, e, http.StatusInternalServerError)
		return
	}

	resp_body, code, resp_err := p.EndpointReq()

	if resp_err != nil {
		e := fmt.Sprintf("put_item_route.PutItemJSONHandler:err %s",
			resp_err.Error())
		log.Printf(e)
		http.Error(w, e, http.StatusInternalServerError)
		return
	}

	if ep.HttpErr(code) {
		route_response.WriteError(w, code, "put_item_route.PutItemJSONHandler", resp_body)
		return
	}

	mr_err := route_response.MakeRouteResponse(
		w,
		req,
		resp_body,
		code,
		start,
		put.ENDPOINT_NAME)
	if mr_err != nil {
		e := fmt.Sprintf("put_item_route.PutItemJSONHandler %s", mr_err.Error())
		log.Printf(e)
	}
}
// BBPD-only endpoint.
// PutItemJSONHandler relays the PutItem request to Dynamo but first validates it through a local type.
// This variant allows the Item to be encoded as basic JSON. As there is always a conversion that
// needs to be performed from a PutIemJSON struct to a PutItem, this endpoint cannot utilize
// RawPost.
BBPD-only endpoint.
PutItemJSONHandler relays the PutItem request to Dynamo but first validates it through a local type.
This variant allows the Item to be encoded as basic JSON. As there is always a conversion that
needs to be performed from a PutIemJSON struct to a PutItem, this endpoint cannot utilize
RawPost.
// BBPD - only endpoint . // PutItemJSONHandler relays the PutItem request to Dynamo but first validates it through a local type . // This variant allows the Item to be encoded as basic JSON . As there is always a conversion that // needs to be performed from a PutIemJSON struct to a PutItem this endpoint cannot utilize // RawPost .
func PutItemJSONHandler(w http.ResponseWriter, req *http.Request) {
	if bbpd_runinfo.BBPDAbortIfClosed(w) {
		return
	}
	start := time.Now()
	if req.Method != "POST" {
		e := "put_item_route.PutItemJSONHandler:method only supports POST"
		log.Printf(e)
		http.Error(w, e, http.StatusBadRequest)
		return
	}
	pathElts := strings.Split(req.URL.Path, "/")
	if len(pathElts) != 2 {
		e := "put_item_route.PutItemJSONHandler:cannot parse path. try /put-item, call as POST"
		log.Printf(e)
		http.Error(w, e, http.StatusBadRequest)
		return
	}
	bodybytes, read_err := ioutil.ReadAll(req.Body)
	req.Body.Close()
	if read_err != nil && read_err != io.EOF {
		e := fmt.Sprintf("put_item_route.PutItemJSONHandler err reading req body: %s", read_err.Error())
		log.Printf(e)
		http.Error(w, e, http.StatusInternalServerError)
		return
	}
	p_json := put.NewPutItemJSON()
	um_err := json.Unmarshal(bodybytes, p_json)
	if um_err != nil {
		e := fmt.Sprintf("put_item_route.PutItemJSONHandler unmarshal err on %s to PutExpected: %s", string(bodybytes), um_err.Error())
		log.Printf(e)
		http.Error(w, e, http.StatusInternalServerError)
		return
	}
	p, perr := p_json.ToPutItem()
	if perr != nil {
		e := fmt.Sprintf("put_item_route.PutItemJSONHandler cannot convert PutItemJSON to PutItem:%s", perr.Error())
		log.Printf(e)
		http.Error(w, e, http.StatusInternalServerError)
		return
	}
	resp_body, code, resp_err := p.EndpointReq()
	if resp_err != nil {
		e := fmt.Sprintf("put_item_route.PutItemJSONHandler:err %s",
			resp_err.Error())
		log.Printf(e)
		http.Error(w, e, http.StatusInternalServerError)
		return
	}
	if ep.HttpErr(code) {
		route_response.WriteError(w, code, "put_item_route.PutItemJSONHandler", resp_body)
		return
	}
	mr_err := route_response.MakeRouteResponse(
		w,
		req,
		resp_body,
		code,
		start,
		put.ENDPOINT_NAME)
	if mr_err != nil {
		e := fmt.Sprintf("put_item_route.PutItemJSONHandler %s", mr_err.Error())
		log.Printf(e)
	}
}
func PutItemJSONHandler ( w http . ResponseWriter , req * http . Request ) { if bbpd_runinfo . BBPDAbortIfClosed ( w ) { return } start := time . Now ( ) if req . Method != " " { e := " " log . Printf ( e ) http . Error ( w , e , http . StatusBadRequest ) return } pathElts := strings . Split ( req . URL . Path , " " ) if len ( pathElts ) != 2 { e := " " log . Printf ( e ) http . Error ( w , e , http . StatusBadRequest ) return } bodybytes , read_err := ioutil . ReadAll ( req . Body ) req . Body . Close ( ) if read_err != nil && read_err != io . EOF { e := fmt . Sprintf ( " " , read_err . Error ( ) ) log . Printf ( e ) http . Error ( w , e , http . StatusInternalServerError ) return } p_json := put . NewPutItemJSON ( ) um_err := json . Unmarshal ( bodybytes , p_json ) if um_err != nil { e := fmt . Sprintf ( " " , string ( bodybytes ) , um_err . Error ( ) ) log . Printf ( e ) http . Error ( w , e , http . StatusInternalServerError ) return } p , perr := p_json . ToPutItem ( ) if perr != nil { e := fmt . Sprintf ( " " , perr . Error ( ) ) log . Printf ( e ) http . Error ( w , e , http . StatusInternalServerError ) return } resp_body , code , resp_err := p . EndpointReq ( ) if resp_err != nil { e := fmt . Sprintf ( " " , resp_err . Error ( ) ) log . Printf ( e ) http . Error ( w , e , http . StatusInternalServerError ) return } if ep . HttpErr ( code ) { route_response . WriteError ( w , code , " " , resp_body ) return } mr_err := route_response . MakeRouteResponse ( w , req , resp_body , code , start , put . ENDPOINT_NAME ) if mr_err != nil { e := fmt . Sprintf ( " " , mr_err . Error ( ) ) log . Printf ( e ) } }
BBPD-only endpoint.
BBPD - only endpoint .