Skip to content

FetchWeb/Fetch

Repository files navigation

Go Webserver

License: MIT Go Report Card Go Doc Build Status Release

This is an experimental web server written in Go. Do not use in production.

How to get set up

Create a new Go project and put this in your main.go file:

package main

import (
	"fmt"
	"fetch/core"
)

func main() {
	app := core.Server{}

	app.Setup()

	app.GetRouter().Get("/", homeHandler)

	app.Start()
}

func homeHandler(w core.Response, r core.Request) {
	fmt.Fprint(w, "Hello Go!\n")
}

You can change the port by setting the "_port" parameter on the Server struct:

app := core.Server{Port: "80"}

If you're using SSL or static file hosting, it's important to specify the projects base directory in the server struct:

baseDir, _ := os.Getwd()
app := core.Server{BaseDir: baseDir}

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages