github.com/blend/go-sdk@v1.20220411.3/web/doc.go (about)

     1  /*
     2  
     3  Copyright (c) 2022 - Present. Blend Labs, Inc. All rights reserved
     4  Use of this source code is governed by a MIT license that can be found in the LICENSE file.
     5  
     6  */
     7  
     8  /*
     9  Package web implements a model view controller system for building http servers.
    10  It is meant to be composed with other packages to form everything from small api servers
    11  to fully formed web view applications.
    12  
    13  Basics
    14  
    15  To create a web server:
    16  
    17  	import "github.com/blend/go-sdk/graceful"
    18  	import "github.com/blend/go-sdk/logger"
    19  	import "github.com/blend/go-sdk/web"
    20  
    21  	...
    22  
    23  	app := web.MustNew(web.OptBindAddr(os.Getenv("BIND_ADDR")))
    24  	app.GET("/", func(_ *web.Ctx) web.Result {
    25  		return web.Text.Result("hello world")
    26  	})
    27  	if err := graceful.Shutdown(app); err != nil {
    28  		logger.FatalExit(err)
    29  	}
    30  
    31  This will start a web server with a trivial endpoint mounted at the path "/" for the HTTP Verb "GET".
    32  This example will also start the server and listen for SIGINT and SIGTERM os signals,
    33  and close the server gracefully if they're received, letting requests finish.
    34  
    35  There are many more examples in the github.com/blend/go-sdk/examples/web directory.
    36  */
    37  package web // import "github.com/blend/go-sdk/web"