Categorygithub.com/ahmetson/web-lib
modulepackage
0.0.0-20231023182034-9ecf7b76cd6e
Repository: https://github.com/ahmetson/web-lib.git
Documentation: pkg.go.dev

# README

Web lib

An extended handler that runs on HTTP protocol. Use it to support Http in your services.

The handler is defined in handler.go. The HTTP protocol layer is defined in the web.go.

The HTTP protocol is based on valyala/fasthttp.

The messages are received only in POST method. Supports only message.Request in the POST body.

Usage

package main

import (
	"github.com/ahmetson/datatype-lib/data_type/key_value"
	"github.com/ahmetson/datatype-lib/message"
	"github.com/ahmetson/handler-lib/config"
	"github.com/ahmetson/web-lib"
)

func onIndex(req message.Request) *message.Reply {
	return req.Ok(key_value.Empty())
}

func main() {
	handlerConfig, _ := config.NewHandler(config.ReplierType, "web")
	handlerConfig.Port = 80

	handler, _ := web.New()
	handler.SetConfig(handlerConfig)
	_ = handler.Route("index", onIndex)
	_ = handler.Start()
}

Todo

  • Add a routing to map to the GET paths.
  • Add support for the raw message

# Functions

No description provided by the author

# Constants

No description provided by the author
No description provided by the author

# Structs

No description provided by the author