Skip to content

PiterWeb/Alf-Router

Folders and files

NameName
Last commit message
Last commit date

Latest commit

8d3c269 Β· Jan 4, 2024

History

88 Commits
Aug 1, 2023
Jan 4, 2024
Aug 11, 2023
Aug 1, 2023
Aug 5, 2023
Aug 8, 2022
Aug 11, 2023
Jan 4, 2024
Aug 8, 2023
Jan 4, 2024
Jan 4, 2024
Aug 1, 2023
Jan 4, 2024
Jan 4, 2024
Aug 1, 2023
Jan 4, 2024
Aug 8, 2023
Jan 4, 2024

Repository files navigation

🦌 ALF (API Like Flutter) Router

πŸ”΄ This library is actually well tested but the API may change with the time introducing breaking changes

Description

πŸ‘‰ This is a micro-framework / router built on ⬆ top of the fasthttp package. Alf relies on scalability and his simple structure wich is similar to Flutter projects πŸ“΄

✨ Inspired by Flutter & Fiber

Purpouse

πŸ‘·β€β™‚οΈ Make a router to start faster and simpler my backend projects

πŸ“– Learn

  • Explore the fasthttp package ⏭
  • Publish my own package πŸ“¦
  • Learn more deeply how a web server works 🌐

Technologies used πŸ“˜

  • Go (Golang)

Core External Packages πŸ“¦:

  1. fasthttp (http ☁)
  2. ffjson (parse interfaces to json fast)
  3. pterm (show info, errors & warnings)

Features :

  • Fast Router πŸ’¨
  • Concurrent Route Setup ⌚
  • Send JSON Responses (docs)
  • HTML/Go Templates Out of the BOX ✨ (docs)
  • Plugins 🧩 :
    • Generate Types for TS (tygo pkg) (docs)

Docs

Prerequisites πŸ“Œ

Set up your first project πŸ’»

Download the package ⬇

go get github.com/PiterWeb/Alf-Router

Import it into your code πŸ” 

    import (
	    alf "github.com/PiterWeb/Alf-Router"
    )

Write this simple structure

    err := alf.App(&alf.AppConfig{
		Port: "3000",
		Routes: alf.CreateRouter([]alf.Route{
			{
				Path: "/",
				Handle: func(ctx *alf.Ctx) error {
					_, err := ctx.WriteString("Hello World")
					return err
				},
				Method: "get",
			},
		}),
	})

	if err != nil {
		panic(err)
	}

Now you have setup πŸ”¨ an index route