Basic Auth

In HTTP, Basic Access Authentication is a form of login authentication that allows web browsers or other client programs to provide credentials in the form of a username and password upon request. Hertz also provides an implementation of Basic Auth, referencing gin’s implementation.

As for usage, you may refer to hertz example and gin documentation

package main

import (


func main() {
	h := server.Default(server.WithHostPorts(""))
		"test1": "value1",
		"test2": "value2",

	h.GET("/basicAuth", func(ctx context.Context, c *app.RequestContext) {
		c.String(consts.StatusOK, "hello hertz")