mahakam

package module
v1.0.0-rc8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 12, 2025 License: MIT Imports: 8 Imported by: 0

README

Mahakam

Official Documentation Go Report Card Go Reference GitHub Release

Mahakam is a HTTP Framework for go written over netpoll. Designed to be used with net/http package. It's mean you didn't need a learn another framework to use it.

Features

  • Easy to use
  • Compatible with net/http package. it's mean you didn't need a learn another framework to use it.
  • Websocket support
  • Has a lot built-in middlewares and extensions (stil in development)

Notes

[!WARNING] This project is still in development. If you wan't to use it in production, please just use net/http package.
You can still use Mahakam features like websocket, middleware, or extension without any configuration with net/http package.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Middleware

type Middleware = func(http.HandlerFunc) http.HandlerFunc

Middleware defines a middleware parameter type for the server.

type NetworkFramework

type NetworkFramework string
const (
	HTTP    NetworkFramework = "net/http"                     // Standard HTTP package
	NET     NetworkFramework = "net"                          // Standard net package
	NETPOLL NetworkFramework = "github.com/cloudwego/netpoll" // Netpoll package, a high-performance network library (https://github.com/cloudwego/netpoll)
)

func (NetworkFramework) IsValid

func (nf NetworkFramework) IsValid() bool

func (NetworkFramework) String

func (nf NetworkFramework) String() string

type RW

type RW struct {
	// contains filtered or unexported fields
}

RW is a custom ResponseWriter that implements the http.ResponseWriter interface.

func NewRW

func NewRW(conn net.Conn) *RW

func (*RW) Header

func (w *RW) Header() http.Header

func (*RW) Hijack

func (w *RW) Hijack() (net.Conn, *bufio.ReadWriter, error)

func (*RW) Reader

func (w *RW) Reader() *bufio.Reader

func (*RW) Write

func (w *RW) Write(data []byte) (int, error)

func (*RW) WriteHeader

func (w *RW) WriteHeader(statusCode int)

func (*RW) Writer

func (w *RW) Writer() *bufio.Writer

type Server

type Server struct {
	Address string

	ErrorHandler func(http.ResponseWriter, *http.Request, error)
	TLS          bool
	// contains filtered or unexported fields
}

Server is a custom HTTP server that uses netpoll for handling connections.

func NewServer

func NewServer(address string, mux *http.ServeMux) *Server

NewServer creates a new Server instance with the specified address and HTTP ServeMux.

func (*Server) Framework

func (s *Server) Framework(framework NetworkFramework)

Framework sets the network framework for the server. by default it uses NETPOLL.

func (*Server) Handle

func (s *Server) Handle(pattern string, handler http.Handler)

Handle binds a handler to a specific pattern in the server's HTTP ServeMux.

func (*Server) HandleFunc

func (s *Server) HandleFunc(pattern string, handler http.HandlerFunc)

HandleFunc binds a handler function to a specific pattern in the server's HTTP ServeMux.

func (*Server) ListenAndServe

func (s *Server) ListenAndServe() error

ListenAndServe starts the server and listens for incoming connections.

func (*Server) ServeFiles

func (s *Server) ServeFiles(pattern string, root http.FileSystem)

ServeFiles serves static files from the specified root directory using the given pattern.

func (*Server) SetTLS

func (s *Server) SetTLS(active bool, certificatePath, keyPath string)

SetTLS enables TLS for the server and sets the certificate and key paths.

func (*Server) Use

func (s *Server) Use(middleware ...func(http.HandlerFunc) http.HandlerFunc)

Use binds middleware functions to the server.

Directories

Path Synopsis
example
cache/map command
cache/redis command
http command
metrics/cmd command
middleware command
tracing/cmd command
websocket command

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL