使用 Go 构建 Web 应用程序 – 中级

了解如何使用 Go (Golang) 构建安全的电子商务应用程序

教程演示🔗

What you’ll learn 学习内容

  • How to build a front end website using Go
    如何使用 Go 构建前端网站
  • How to build a back end API using Go
    如何使用 Go 构建后端 API
  • How to build multiple applications from a single code base
    如何从单个代码库构建多个应用程序
  • How to build microservices in Go
    如何在 Go 中构建微服务
  • User authentication in Go
    Go 中的用户身份验证
  • API authentication using stateful tokens
    使用有状态令牌的 API 身份验证
  • How to allow users to reset a password in a safe, secure manner
    如何允许用户以安全、可靠的方式重置密码
  • How to integrate Stripe credit card processing with a Go back end
    如何将 Stripe 信用卡处理与 Go 后端集成
  • Make one time or recurring payments with Stripe
    使用 Stripe 进行一次性或定期付款
  • Best practices for making secure credit card transactions
    进行安全信用卡交易的最佳实践

Requirements 要求

  • A basic understanding of the Go programming language
    对 Go 编程语言有基本的了解
  • A basic understanding of HTML, CSS, and JavaScript
    对 HTML、CSS 和 JavaScript 有基本的了解
  • A basic understanding of SQL syntax
    对 SQL 语法有基本的了解

Description 描述

This course is the followup to Building Modern Web Applications in Go. In this course, we go further than we did the first time around. We will build a sample E-Commerce application that consists of multiple, separate applications: a front end (which services content to the end user as web pages); a back end API (which is called by the front end as necessary), and a microservice that performs only one task, but performs it extremely well (dynamically building PDF invoices and sending them to customers as an email attachment).
本课程是使用 Go 构建现代 Web 应用程序的后续课程。在本课程中,我们比第一次走得更远。我们将构建一个示例电子商务应用程序,该应用程序由多个独立的应用程序组成:前端(以网页形式向最终用户提供内容);后端 API(由前端根据需要调用),以及仅执行一项任务但执行得非常好(动态构建 PDF 发票并将其作为电子邮件附件发送给客户的微服务)。

The application will sell individual items, as well as allow users to purchase a monthly subscription. All credit card transactions will be processed through Stripe, which is arguably one of the most popular payment processing systems available today, and for good reason: developers love it. Stripe offers a rich API (application programming interface), and it is available in more than 35 countries around the world, and works with more than 135 currencies. Literally millions of organizations and businesses use Stripe’s software and APIs to accept payments, send payouts, and manage their businesses online with the Stripe dashboard. However, in many cases, developers want to be able to build a more customized solution, and not require end users to log in to both a web application and the Stripe dashboard. That is precisely the kind of thing that we will be covering in this course.
该应用程序将销售单个商品,并允许用户购买每月订阅。所有信用卡交易都将通过 Stripe 进行处理,Stripe 可以说是当今最流行的支付处理系统之一,这是有充分理由的:开发人员喜欢它。Stripe 提供丰富的 API(应用程序编程接口),在全球超过 35 个国家/地区可用,支持超过 135 种货币。数以百万计的组织和企业使用 Stripe 的软件和 API 通过 Stripe 管理平台在线接受付款、发送提现和管理业务。然而,在许多情况下,开发人员希望能够构建更加定制的解决方案,而不需要最终用户同时登录 Web 应用程序和 Stripe 管理平台。这正是我们将在本课程中介绍的内容。

We will start with a simple Virtual Terminal, which can be used to process so-called “card not present” transactions. This will be a fully functional web application, built from the ground up on Go (sometimes referred to as Golang). The front end will be rendered using Go’s rich html/template package, and authenticated users will be able to process credit card payments from a secure form, integrated with the Stripe API. In this section of the course, we will cover the following:
我们将从一个简单的虚拟终端开始,它可以用来处理所谓的“无卡”交易。这将是一个功能齐全的 Web 应用程序,在 Go(有时称为 Golang)上从头开始构建。前端将使用 Go 丰富的 html/模板包呈现,经过身份验证的用户将能够通过与 Stripe API 集成的安全表单处理信用卡付款。在本课程的这一部分,我们将介绍以下内容:

  • How to build a secure, production ready web application in Go
    如何在 Go 中构建安全的、生产就绪的 Web 应用程序

  • How to capture the necessary information for a secure online credit card transaction
    如何获取安全在线信用卡交易的必要信息

  • How to call the Stripe API from a Go back end to create a paymentIntent (Stripe’s object for authorizing and making a transaction)
    如何从 Go 后端调用 Stripe API 以创建 paymentIntent(Stripe 用于授权和进行交易的对象)

Once we have that out of the way, we’ll build a second web application in the next section of the course, consisting of a simple web site that allows users to purchase a product, or purchase a monthly subscription. Again, this will be a web application built from the ground up in Go. In this section of the course, we’ll cover the following:
一旦我们解决了这个问题,我们将在课程的下一节中构建第二个 Web 应用程序,由一个简单的网站组成,允许用户购买产品或购买每月订阅。同样,这将是一个用 Go 从头开始构建的 Web 应用程序。在本课程的这一部分中,我们将介绍以下内容:

  • How to allow users to purchase a single product
    如何允许用户购买单个产品

  • How to allow users to purchase a recurring monthly subscription (a Stripe Plan)
    如何允许用户购买每月定期订阅(Stripe 计划)

  • How to handle cancellations and refunds
    如何处理取消和退款

  • How to save all transaction information to a database (for refunds, reporting, etc).
    如何将所有交易信息保存到数据库中(用于退款、报告等)。

  • How to refund a transaction
    如何为交易退款

  • How to cancel a subscription
    如何取消订阅

  • How to secure access to the front end (via session authentication)
    如何保护对前端的访问(通过会话身份验证)

  • How to secure access to the back end API (using stateful tokens)
    如何保护对后端 API 的访问(使用有状态令牌)

  • How to manage users (add/edit/delete)
    如何管理用户(添加/编辑/删除)

  • How to allow users to reset their passwords safely and securely
    如何允许用户安全可靠地重置其密码

  • How to log a user out and cancel their account instantly, over websockets
    如何通过 websocket 注销用户并立即取消其帐户

Once this is complete, we’ll start work on the microservice. A microservice is a particular approach to software development that has the basic premise of building very small applications that do one thing, but do it very well. A microservice does not care in the slightest about what application calls it; it is completely separate, and completely agnostic. We’ll build a microserivce that does the following:
完成此操作后,我们将开始处理微服务。微服务是一种特殊的软件开发方法,其基本前提是构建非常小的应用程序,这些应用程序只做一件事,但做得很好。微服务根本不关心应用程序调用它的内容;它是完全独立的,完全不可知论的。我们将构建一个执行以下操作的微服务:

  • Accepts a JSON payload describing an individual purchase
    接受描述单个购买的 JSON 有效负载

  • Produces a PDF invoice with information from the JSON payload
    生成包含 JSON 有效负载信息的 PDF 发票

  • Creates an email to the customer, and attaches the PDF to it
    创建发送给客户的电子邮件,并将 PDF 附加到该电子邮件

  • Sends the email 发送电子邮件

All of these components (front end, back end, and microservice) will be built using a single code base that produces  multiple binaries, using Gnu Make.
所有这些组件(前端、后端和微服务)都将使用单个代码库构建,该代码库使用 Gnu Make 生成多个二进制文件。

Who this course is for:
本课程适用于谁:

  • Developers who want to integrate Stripe into their applications
    希望将 Stripe 集成到其应用程序中的开发人员
  • Developers who want to learn how to build a back end API in Go
    想要学习如何在 Go 中构建后端 API 的开发人员
  • Developers who want to learn best practices for building modern applications in Go (and JavaScript)
    想要学习使用 Go(和 JavaScript)构建现代应用程序的最佳实践的开发人员

发表回复

后才能评论

尊敬的用户,您好!由于部分培训机构和留学生的举报,近期导致网站大量链接暂时失效。对此给您带来的不便,我们深表歉意。任何链接失效的资源,欢迎您添加侧边栏二维码随时反馈,我们将在48小时内为您提供新的网盘链接。如果您对此不便感到不满,您也可在48小时内申请无理由退款。感谢您的理解与支持!

Windows播放器推荐:Potplayer Potplayer 是免费的 Windows 播放器,支持双字幕和自动翻译功能。以下是操作指南: 挂载字幕 加载中文字幕:右击选择 字幕 -> 字幕设置,取消“只匹配文件名字幕”选项。可调整字幕颜色、位置和大小。 双字幕设置:右击 字幕 -> 选择字幕 -> 次字幕输出,设置主字幕和次字幕。 自动翻译 若可访问 Google 翻译服务,选择 字幕 -> 实时字幕翻译,勾选 总是使用 和 Google Translate,即可实时翻译英文字幕。 Potplayer 让观看更智能,学习体验升级。

最常见的情况是下载不完整: 可对比下载完压缩包的与网盘上的容量,若小于网盘提示的容量则是这个原因。这是浏览器下载的bug,建议用百度网盘软件或迅雷下载。 若排除这种情况,可联络站长解决。

如果您已经成功付款但是网站没有弹出成功提示,请联系站长提供付款信息为您处理

源码素材属于虚拟商品,具有可复制性,可传播性,一旦授予,不接受任何形式的退款、换货要求。请您在购买获取之前确认好 是您所需要的资源