---
title: "4.1.前置准备"
url: "https://goframe.org/course/proxima-book/gateway-prepare"
markdown_url: "https://goframe.org/course/proxima-book/gateway-prepare.md"
locale: "zh-Hans"
version: "2.10.x(Latest)"
section: "实战教程"
category: "实战教程 / proxima-book / 第四章-业务网关"
published: "2024-12-17"
updated: "2024-12-17"
description: "介绍了业务网关的初始化过程，包括使用 GoFrame CLI 创建网关服务、配置项目结构等基础准备工作。"
keywords: ["GoFrame", "gateway initialization", "API Gateway setup", "microservices gateway", "project structure"]
---

# 4.1.前置准备

业务网关和单体`Web`服务基本一致，不同的地方在于，原来的具体业务逻辑交由调用微服务来实现。

## 代码初始化
---
执行以下命令，建立名为`gateway`的服务，同样保存在`app`目录下。

```bash
$ gf init app/gateway -a
initializing...
initialization done! 
you can now run "cd app/gateway && gf run main.go" to start your journey, enjoy!
```

删除下列文件，留下一个空白的环境。
```text
app/word/api/*
app/word/internal/controller/*
app/word/internal/cmd/cmd.go
```

进入仓库，开始正式开发。
```bash
$ cd app/gateway
