vegvisir/pkg/handler/http.go

45 lines
1.7 KiB
Go

// ___ ____ ___ ___
// \ \ / / | _ | __| \ \ / / || | __ || || _ |
// \ \/ / |___ | |__ \ \/ / || |___ || ||___|
// \ / | _ | _ | \ / || __ | || ||\\
// \/ |___ |___ | \/ || ____| || || \\
//
// Copyright (c) 2021 Piotr Biernat. https://pbiernat.dev. MIT License
// Repo: https://git.pbiernat.dev/golang/vegvisir
// Package handler contain handlers for various protocols
package handler
//func (s *Server) httpHandler(ctx *fasthttp.RequestCtx) {
// // http := client.NewHttpClient(ctx)
//
// // move all below logic to concrete handler or sth....
// reqURL, sReqURL, sReqMethod := ctx.RequestURI(), string(ctx.RequestURI()), string(ctx.Method())
// //log.Println("Incoming request:", sReqMethod, sReqURL)
//
// found, route := s.router.FindByRequestURL(reqURL)
// if !found {
// // FIXME: return 404 or 5xx error in response? Maybe define it in concrete Backend config?
// ctx.SetStatusCode(fasthttp.StatusNotFound)
// //ctx.SetConnectionClose()
//
// log.Println("404:", sReqMethod, sReqURL)
// return
// }
//
// response, err := s.respCM.Fetch(sReqURL, sReqMethod, route)
// if err != nil {
// // FIXME: Response read error(sending 500 error response)
// ctx.SetStatusCode(fasthttp.StatusInternalServerError)
// //ctx.SetConnectionClose() // not sure if change abything with connection: keep-alive/close issue ^^
//
// log.Println("Response read error(sending 500 error response)", err)
// return
// }
//
// ctx.Response.Header.SetBytesV(fasthttp.HeaderContentType, response.Headers.ContentType())
// ctx.SetStatusCode(response.Code)
// ctx.SetBodyString(response.Body)
// //ctx.SetConnectionClose()
//}