Skip to content

A web controller to use in the Ahmetson's framework

License

Notifications You must be signed in to change notification settings

ahmetson/web-lib

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

A web controller to use in the Ahmetson's framework

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Languages