Exemplo n.º 1
0
func prepareRequest(r *http.Request) (storage.Storage, []byte, error) {
	store, err := storage.GenerateStorage(storage.Postgres)
	if err != nil {
		return store, nil, err
	}
	body, err := gowebutils.PrepareRequestBody(r)
	log.Printf("Request body: %v", string(body))
	return store, body, err
}
Exemplo n.º 2
0
// Makes a request and stores the result. Logs any errors.
func makeAndStoreRequest(requestId string, data RequestData) {
	resp, err := makeRequest(data)
	if err != nil {
		log.Printf("[Store Request][Error] Unable to make request: %v", err)
		return
	}
	store, err := storage.GenerateStorage(storage.Postgres)
	if err != nil {
		log.Printf("[Store Request][Error] Unable to open storage: %v", err)
		return
	}
	defer store.Close()
	log.Printf("Received response. request_id=%v status=%v", requestId, resp.Status)
	_, err = store.StoreResponse(requestId, resp)
	if err != nil {
		log.Printf("[Store Request][Error] Unable to store response: %v", err)
		return
	}
}