From d17fbfc792bddb360f1d35d3ad53cff7c8fcb698 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Greinhofer?= Date: Wed, 14 Aug 2024 11:48:50 -0500 Subject: [PATCH] Fix paginated response headers (#137) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Ensures paginated responses content type is set to application/json. Signed-off-by: Rémy Greinhofer --- lambdas/src/lib.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lambdas/src/lib.rs b/lambdas/src/lib.rs index d152d19..df9f785 100644 --- a/lambdas/src/lib.rs +++ b/lambdas/src/lib.rs @@ -9,7 +9,7 @@ use effortless::{ error::{APIError, APIErrors}, fragment::BnaRequestExt, }; -use lambda_http::{Body, Error, Request, Response}; +use lambda_http::{http::header, Body, Error, Request, Response}; use sea_orm::{Database, DatabaseConnection, DbErr}; use serde_json::Value; use std::env; @@ -142,6 +142,7 @@ pub fn build_paginated_response( .header("x-prev-page", nav.prev()) .header("x-total", total_items) .header("x-total-pages", nav.last()) + .header(header::CONTENT_TYPE, "application/json") .body(body.to_string().into()) .map_err(Box::new)?) }