Skip to content

mr-tron/fasthttp2nethttp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Fasthttp handlers wrapper

You can adapt fasthttp handlers for serving with default net/http handlers or rewrap them to over frameworks

Based on https://github.com/gofiber/adaptor/.

Usage

import (
 "github.com/mr-tron/fasthttp2nethttp"
)
func MyOldLegacyFasthttpHandler(ctx *fasthttp.RequestCtx) {
		body, err := json.Marshal(struct{Status string}{"Ok"})
    	if err != nil {
    		return err
    	}
    	ctx.SetContentType("application/json")
    	ctx.SetStatusCode(fasthttp.StatusOK)
    	ctx.SetBody(body)
}


func main() {
handler := fasthttp2nethttp.FastHTTPHandlerWrapper(MyOldLegacyFasthttpHandler)
// now you can serve handler with any framework like default net/http or wrap for another framework like echo.

}

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages