Skip to content
This repository was archived by the owner on May 19, 2023. It is now read-only.

gofiber/rewrite

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Install

go get -u github.com/gofiber/fiber
go get -u github.com/gofiber/rewrite

Example

package main

import (
  "github.com/gofiber/fiber"
  "github.com/gofiber/rewrite"
)

func main() {
  app := fiber.New()
  
  app.Use(rewrite.New(rewrite.Config{
    Rules: map[string]string{
      "/old":   "/new",
      "/old/*": "/new/$1",
    },
  }))
  
  app.Get("/new", func(c *fiber.Ctx) {
    c.Send("Hello, World!")
  })
  app.Get("/new/*", func(c *fiber.Ctx) {
    c.Send("Wildcard: ", c.Params("*"))
  })
  
  app.Listen(3000)
}

Test

curl http://localhost:3000/old
curl http://localhost:3000/old/hello