Introduction
WebServer
requires the support of methods/objects to provide services. The ghttp
package supports multiple route registration modes, providing developers with very powerful and flexible API functionality.
Route registration is the most core part of the entire WebServer
and one of the most carefully designed modules in the goframe
framework.
API documentation: https://pkg.go.dev/github.com/gogf/gf/v2/net/ghttp
Considerations
Starting from version v2
of the framework, the feature of standardized routing has been added, making it more suitable for engineering scenarios in business projects. It is recommended to use standardized routing in complex business projects: Standard Router
Documents
📄️ Registration - Function
In the GoFrame framework, route registration mainly explores the flexibility of function registration methods. Through examples, it demonstrates how to use package methods and object methods for route function registration and how to ensure concurrent safety. Examples include generating a simple 'Hello World' and calculating the total number of visits, implementing access count maintenance through the use of the concurrent-safe type gtype.Int.
📄️ Registration - Object
Object registering executes route registration through an instantiated object. Each request is handled by the object, remaining in memory without being released. This document introduces methods related to object registering in the GoFrame framework, such as BindObject, BindObjectMethod, and BindObjectRest, and explains how objects are registered following RESTful design. Additionally, it discusses built-in route variables, naming conventions, and Init and Shut constructor and destructor methods.
📄️ Registration - Group Routing
Route registration using group routing in the GoFrame framework. Group routing is a recommended route registration method that supports hierarchical and batch registration. Users can set unique HTTP Methods and apply middleware for each route. These features help developers manage and optimize project routing structures more efficiently.
🗃️ Standard Router
3 items