반응형

슬기로운 개발자생활/Backend 5

Rust AXUM+MongoDB로 RestAPI 서버 개발하기 - AWS S3 연동 이미지 업로드

Rust를 사용한 Axum 서버에서 Amazon S3에 이미지를 저장하는 과정에서 Pre-signed URL을 활용하는 방법은 클라이언트가 서버를 거치지 않고 직접 S3에 파일을 업로드할 수 있게 해주면서도 보안을 유지할 수 있는 효율적인 방법입니다. 이 과정에서 Axum 서버는 Pre-signed URL을 생성하고, 업로드 될 파일의 content_type과 S3 key를 관리하여 데이터베이스에 저장하는 로직만 수행합니다. 다음은 이 과정을 설명하기 위한 순서와 설명입니다: 0. 사전 준비 사항 AWS 이미지를 저장해놓을 S3 Bucket 디렉토리 구조는 원본 이미지를 저장해놓을 raw/ 이미지 크기 별 폴더 w140/ w600/로 구분해놓았습니다. lambda 활용하여 이미지 크기를 조정하여 저장해놓..

Rust AXUM+MongoDB로 RestAPI 서버 개발하기 - 프로젝트 설정

Rust AXUM을 활용한 RestfulAPI 웹 애플리케이션 서버를 개발해봅시다. 전체적인 폴더구조, 흐름은 다음과 같습니다. 프로젝트 시작 cargo new {project_name} --bin 0. 프로젝트 폴더 구조 src/ |-- main.rs |-- .env |-- {domain}/ |-- mod.rs |-- entity.rs |-- handler.rs |-- usecase.rs |-- repository.rs |-- dto/ |-- mod.rs |-- req.rs |-- res.rs |-- config/ |-- mod.rs |-- database.rs 1. 필수 패키지 설치 먼저, 프로젝트를 시작하기 전에 Cargo.toml 파일에 다음 패키지들을 추가해야 합니다: axum: 웹 애플리케이션..

Dealing with sub-packages (or sub-modules) in Rust

When dealing with sub-packages (or sub-modules) in Rust, especially in larger projects like an axum web application, structuring your code effectively is key to maintaining clarity and manageability. Let's address your example structure and how you can organize and reference these modules and sub-modules. Given your project structure: src/main.rs src/photo/handler.rs src/photo/usecase.rs src/pho..

Mastering Rust: A Guide to Managing Modules and Packages

Introduction: Rust, a system programming language known for its safety and performance, offers a powerful module system that facilitates the organization and reuse of code. Understanding how to effectively manage modules and packages is essential for Rust developers looking to build robust and maintainable applications. This guide will take you through the basics of Rust's module system, package..

Understanding Result, map_err, ?, Ok, and Err in Rust with Axum JWT Authentication

Rust's powerful error handling model is exemplified by its use of the Result type, which represents either success (Ok) or failure (Err). This model encourages explicit handling of all possible errors, making Rust programs more robust and reliable. In the context of web development with Axum, a web framework for Rust, understanding how to effectively use Result, map_err, ?, Ok, and Err is crucia..

반응형