golux

package module
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: May 16, 2024 License: MIT Imports: 4 Imported by: 0

README

Golux

Golux is a lightweight HTTP router designed specifically for use with AWS Lambda functions consuming ApiGatewayProxyRequest events. It simplifies the process of routing HTTP requests to specific Lambda handlers within your Go application.

Features

  • Simple Routing: Golux provides a straightforward API for defining routes and associating them with Lambda handlers.
  • Integration with AWS Lambda and API Gateway: Golux is tailored to seamlessly work with Lambda functions that consume ApiGatewayProxyRequest events, making it an ideal choice for building serverless applications on AWS.

Installation

To use Golux in your Go application, simply install it using go get:

go get -u github.com/DuncanScu/golux

Usage

//main.go
package main

func main(){
	mux := golux.NewRouter()
	mux.Handle(http.MethodGet, "/test", testHandler)
	lambda.Start(mux.HandleRequest)
}

func testHandler(request events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error) {
	return events.APIGatewayProxyResponse{StatusCode: http.StatusAccepted}, nil
}

Contributing

Contributions to Golux are welcome! If you have suggestions, bug reports, or would like to contribute code, please open an issue or submit a pull request on GitHub.

Documentation

Overview

Package golux provides a lightweight HTTP router designed for serverless applications.

golux allows you to define routes and handlers for incoming HTTP requests in AWS Lambda functions, using a simple and efficient routing mechanism based on a tree structure.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HandlerFunc

type HandlerFunc common.HandlerFunc

HandlerFunc defines the signature for HTTP request handlers.

type Router

type Router struct {
	PathTree *tree.PathTree
}

Router is a lightweight HTTP router.

func NewRouter

func NewRouter() *Router

NewRouter creates a new Router instance.

func (*Router) Handle

func (r *Router) Handle(method string, path string, fn common.HandlerFunc)

Handle registers a new handler for the specified HTTP method and path pattern.

func (*Router) HandleRequest

HandleRequest handles an incoming API Gateway Proxy request and dispatches it to the appropriate handler. It returns an API Gateway Proxy response and an error, if any.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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