- عنوان کتاب: Modern REST API Development in Go -Design performant, secure, and observable web APIs using Gos powerful standard library
- نویسنده: Jesús Espino
- حوزه: توسعه API
- سال انتشار: 2025
- تعداد صفحه: 259
- زبان اصلی: انگلیسی
- نوع فایل: pdf
- حجم فایل: 4.59 مگابایت
در محیط بسیار بههمپیوستهی امروزی، APIهای REST زبان میانجی برای نرمافزارهای مختلف جهت ارتباط با یکدیگر هستند. این صنعت در گذشته سیستمهای ارتباطی مختلفی مانند SOAP، CORBA و راهحلهای سفارشی را امتحان کرده است، اما REST استاندارد بالفعل بوده است. سادگی و توانایی آن در بهرهبرداری از فناوریهای زیربنایی، مانند پروتکل HTTP، REST را به گزینهی اصلی برای اکثر توسعهدهندگان تبدیل کرده است.
REST یک گزینهی مطمئن است، اما REST را میتوان با زبانهای زیادی مانند پایتون، روبی، PHP، Rust و غیره اجرا کرد. اما ما قصد داریم در مورد نحوهی انجام این کار با Go صحبت کنیم، اما چرا Go؟ Go یک زبان مدرن، قوی، سریع و آسان برای یادگیری است که آن را برای APIهای REST ایدهآل میکند. کامپایل بومی آن، آن را به کاندیدای شگفتانگیزی برای الزامات سرعت APIهای مدرن تبدیل میکند. تایپ قوی آن، آن را برای تضمین ایمنی و استحکام در خدمات شما ایدهآل میکند و سادگی آن تضمین میکند که ادغام توسعهدهندگان جدید، حتی اگر نیاز به یادگیری زبان داشته باشند، به کابوس تبدیل نخواهد شد. این کتاب REST و Go را پوشش میدهد، اما من به درک مبانی چیزها اعتقاد راسخ دارم، بنابراین در مورد موضوعاتی مانند پروتکل HTTP مورد استفاده در زیر کاپوت، رویکردهای حافظه پنهان، قابلیت مشاهده، امنیت و موارد دیگر نیز بحث خواهیم کرد. این کتاب مهارتهای لازم برای توسعه APIهای REST در Go را به شما ارائه میدهد و به شما میآموزد که چرا از این رویکرد پیروی میکنیم و مفاهیم فناوری پشت آن چیست.
من میخواهم روی مفاهیم تمرکز کنم و تا حد امکان همه چیز را ساده و نزدیک به کتابخانه استاندارد Go نگه دارم و فقط زمانی که هیچ بسته داخلی این امکان را برای ما فراهم نمیکند، کتابخانههای تخصصی را پوشش دهم. با این حال، ما همچنین مثالهایی برای کسانی که رویکردهای متفاوتی را برای انجام کارها ترجیح میدهند، مانند استفاده از سازندگان پرس و جو، ORMها، چارچوبها یا کتابخانههای ادعای آزمایش، ارائه خواهیم داد و به شما در مورد اینکه میخواهید کنترل دقیق را کجا قرار دهید و کجا میخواهید به کتابخانههایی که زندگی شما را آسانتر میکنند، واگذار کنید، حرف آخر را میزنیم.
این کتاب برای توسعهدهندگانی است که میخواهند درک عملی از نحوه ساخت APIهای REST به طور کلی و به طور خاصتر، با استفاده از زبان برنامهنویسی Go به دست آورند. اگرچه برای بهرهمندی از این کتاب، دانش در مورد Go کاملاً ضروری نیست، اما برای بهرهمندی حداکثری از آن، درک حداقلی از آن لازم است.
فصل ۱، مقدمهای بر APIها، مفاهیم اساسی APIهای REST را بررسی میکند و جایگزینهای دیگری مانند SOAP و GraphQL را بررسی میکند.
فصل ۲، بررسی APIهای REST، ابزارهای مورد نیاز برای بررسی و تحلیل APIهای موجود، مانند cURL و Postman را پوشش میدهد. این به شما امکان میدهد APIهای خود را در فصلهای بعدی بررسی و آزمایش کنید.
فصل ۳، ساخت یک کلاینت REST، ابزارهای ارائه شده توسط کتابخانه استاندارد Go برای دسترسی به APIها و نحوه ساخت کتابخانه کلاینت خود برای استفاده از یک API موجود را شرح میدهد.
فصل ۴، طراحی API REST شما، مفاهیم اصلی APIهای REST مانند مسیرها، منابع و اقدامات و معانی مرتبط با آنها در اکوسیستم API REST را معرفی میکند. فصل ۵، احراز هویت و مجوزدهی، نیازها و روشهای مورد استفاده برای اجرای احراز هویت صحیح در مجوزدهی در API شما را بررسی میکند و مفاهیمی مانند JWT یا هدر احراز هویت HTTP را شرح میدهد.
فصل ۶، پایداری دادهها، دانش لازم برای ایجاد لایه پایداری برنامه شما، از جمله استفاده از پایگاه داده SQL، الگوی مخزن و ساخت کوئریها با استفاده از سازنده کوئری Squirrel را ارائه میدهد.
فصل ۷، امنیت API، ویژگیهای امنیتی مختلف ارائه شده توسط پروتکل HTTP و استفاده شده توسط APIهای REST را بررسی میکند. این فصل مواردی مانند اعتبارسنجی دادهها، پاکسازی و مدیریت رمز عبور را پوشش میدهد.
فصل ۸، عملکرد API، بر سریع کردن API شما تمرکز دارد، از جمله موضوعاتی مانند کنترل حافظه پنهان از پروتکل HTTP، پروفایلر Go و ساخت و درک معیارها در کد Go.
فصل ۹، استقرار API شما، گزینههای مختلف برای استقرار APIهای REST را بررسی میکند، از استقرار API شما در سختافزار خام گرفته تا رویکردی پیچیدهتر مانند Kubernetes یا تابع به عنوان سرویس. فصل 10، تست، ابزارهای مختلفی را که Go برای تست ارائه میدهد و انواع مختلف تستهایی که میتوانید بسازید، از تستهای واحد گرفته تا تستهای یکپارچهسازی، را بررسی میکند و همه آنها را بررسی میکند. ما همچنین کتابخانه testify assertion را به عنوان جایگزینی برای ابزارهای تست کتابخانه استاندارد Go بررسی میکنیم.
فصل 11، مستندسازی با OpenAPI، ارزش مستندسازی صحیح REST API شما را با ابزار استاندارد ارائه شده توسط ابتکار OpenAPI نشان میدهد. این شامل تولید مستندات و ارائه آن به ابزارهایی مانند Postman است.
فصل 12، معیارها، گزارشها و ردیابیها، مفاهیم مشاهدهپذیری را برای برنامه REST API شما معرفی میکند. این فصل دادههایی را که جمعآوری میکنیم (معیارها، گزارشها و ردیابیها) بررسی میکند. همچنین ابزارهایی را که به شما در درک دادههای جمعآوریشده کمک میکنند، مانند Jaeger و Grafana، بررسی میکند.
فصل 13، استفاده از GORM، یک رویکرد جایگزین برای لایه ذخیرهسازی ارائه میدهد و آن را با GORM به جای کتابخانه استاندارد یا کتابخانه Squirrel میسازد…
In today’s extremely interconnected environment, REST APIs are the lingua franca for different software to communicate with each other. The industry has tried different communication systems in the past, such as SOAP, CORBA, and custom-made solutions, but REST has been the de facto standard. Its simplicity and ability to leverage the underlying technologies, such as the HTTP protocol, have positioned REST as the go-to option for most developers.
REST is a solid option, but REST can be executed with many languages, such as Python, Ruby, PHP, Rust, and so on. But we are going to talk about how to do it with Go, but why Go? Go is a modern, robust, fast, and easy-to-learn language, making it ideal for REST APIs. Its native compilation makes it an amazing candidate for the speed requirement of modern APIs; its strong typing makes it perfect for ensuring safety and robustness in your services, and its simplicity ensures that incorporating new developers, even if they need to learn the language, is not going to become a nightmare.
This book covers REST and Go, but I’m a firm believer in understanding the foundations of things, so we will also discuss topics such as the HTTP protocol used under the hood, cache approaches, observability, security, and much more. It provides you with the skills to develop REST APIs in Go and teaches you why we follow that approach and what the technological concepts are behind it.
I want to focus on the concepts and keep things as simple and close to the Go standard library as possible, covering specialized libraries only when no built-in package provides that for us. However, we will also provide examples for those who prefer different approaches to doing things, such as using query builders, ORMs, frameworks, or testing assertion libraries, giving you the final say on where you want to put the fine-grain control, and where you want to delegate to libraries that make your life easier.
This book is for developers who want to gain a practical understanding of how to build REST APIs in general and, more specifically, using the Go programming language. While knowledge about Go is not strictly needed to get value from this book, some minimal understanding is required to get the most out of it.
Chapter 1, Introduction to APIs, goes through the fundamental concepts of REST APIs and explores other alternatives such as SOAP and GraphQL.
Chapter 2, Exploring REST APIs, covers the tools needed to explore and analyze existing APIs, such as cURL and Postman. It enables you to explore and test your own APIs in the following chapters.
Chapter 3, Building a REST Client, exposes the tools provided by Go’s standard library for accessing APIs, and how you can build your own client library for consuming an existing API.
Chapter 4, Designing Your REST API, introduces the main concepts of REST APIs such as routes, resources, and actions, and the semantics associated with them in the REST API ecosystem.
Chapter 5, Authentication and Authorization, explores the needs and methods used for enforcing proper authentication in authorization in your API, exposing concepts such as JWT or the authentication HTTP header.
Chapter 6, Data Persistency, provides the knowledge needed to create the persistency layer of your application, including SQL database usage, the repository pattern, and building queries using the Squirrel query builder.
Chapter 7, API Security, goes through the different security features provided by the HTTP protocol and leveraged by the REST APIs. The chapter covers things such as data validation, sanitization, and password handling.
Chapter 8, API Performance, focuses on making your API fast, including topics such as cache control from the HTTP protocol, the Go profiler, and building and understanding benchmarks in Go code.
Chapter 9, Deploying Your API, examines the different options for deploying REST APIs, from deploying your API in bare metal to a more sophisticated approach such as Kubernetes or function as a service.
Chapter 10, Testing, exposes the different tools that Go provides for testing, and the different kinds of tests that you can build, from unit to integration tests, exploring all of them. We also explore the testify assertion library as an alternative to the Go standard library testing tools.
Chapter 11, Documenting with OpenAPI, shows the value of properly documenting your REST API with the standard tooling out there provided by the OpenAPI initiative. It includes generating documentation and exposing that to tools such as Postman.
Chapter 12, Metrics, Logs, and Traces, introduces the concepts of observability for your REST API application. This chapter explores the data that we collect (metrics, logs, and traces). It also ex¬plores the tools that help you understand the collected data, such as Jaeger and Grafana.
Chapter 13, Using GORM, offers an alternative approach for the storage layer, building it with GORM instead of the standard library, or the Squirrel library.
Chapter 14, Using the Echo Framework, explores other ways of generating your API that are not based on the standard library; instead, it uses a third-party framework.
این کتاب را میتوانید از لینک زیر بصورت رایگان دانلود کنید:
Download: Modern REST API Development in Go
نظرات کاربران