github.com/circl-dev/go-swagger@v0.31.0/examples/todo-list/cmd/todo-list-server/main.go (about)

     1  // Code generated by go-swagger; DO NOT EDIT.
     2  
     3  package main
     4  
     5  import (
     6  	"fmt"
     7  	"log"
     8  	"os"
     9  
    10  	"github.com/circl-dev/loads"
    11  	flag "github.com/spf13/pflag"
    12  
    13  	"github.com/circl-dev/go-swagger/examples/todo-list/restapi"
    14  	"github.com/circl-dev/go-swagger/examples/todo-list/restapi/operations"
    15  )
    16  
    17  // This file was generated by the swagger tool.
    18  // Make sure not to overwrite this file after you generated it because all your edits would be lost!
    19  
    20  func main() {
    21  
    22  	swaggerSpec, err := loads.Embedded(restapi.SwaggerJSON, restapi.FlatSwaggerJSON)
    23  	if err != nil {
    24  		log.Fatalln(err)
    25  	}
    26  
    27  	var server *restapi.Server // make sure init is called
    28  
    29  	flag.Usage = func() {
    30  		fmt.Fprint(os.Stderr, "Usage:\n")
    31  		fmt.Fprint(os.Stderr, "  todo-list-server [OPTIONS]\n\n")
    32  
    33  		title := "Simple To Do List API"
    34  		fmt.Fprint(os.Stderr, title+"\n\n")
    35  		desc := "This is a simple todo list API\nillustrating go-swagger codegen\ncapabilities.\n"
    36  		if desc != "" {
    37  			fmt.Fprintf(os.Stderr, desc+"\n\n")
    38  		}
    39  		fmt.Fprintln(os.Stderr, flag.CommandLine.FlagUsages())
    40  	}
    41  	// parse the CLI flags
    42  	flag.Parse()
    43  
    44  	api := operations.NewTodoListAPI(swaggerSpec)
    45  	// get server with flag values filled out
    46  	server = restapi.NewServer(api)
    47  	defer server.Shutdown()
    48  
    49  	server.ConfigureAPI()
    50  	if err := server.Serve(); err != nil {
    51  		log.Fatalln(err)
    52  	}
    53  
    54  }