Skip to content

karlkfi/inject-example-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Inject Example Server

Example Go (golang) web server with dependency injected controllers using the Inject library.

Dependencies

Facebook's Grace library is used for graceful shutdown.

go get github.com/facebookgo/grace

Usage

  1. Launch the server:

    go run main.go
    

    (ctrl-c to quit)

  2. Query Index:

    $ curl http://localhost:8080/; echo
    Welcome to the Inject Example Server!
    
  3. Query User List:

    $ curl http://localhost:8080/users; echo
    {"users":[{"id":"0","name":"Alice"},{"id":"1","name":"Bob"},{"id":"2","name":"Charlie"}]}
    
  4. Query User:

    $ curl http://localhost:8080/user/0; echo
    {"id":"0","name":"Alice"}
    $ curl http://localhost:8080/user/1; echo
    {"id":"1","name":"Bob"}
    $ curl http://localhost:8080/user/2; echo
    {"id":"2","name":"Charlie"}
    

License

Copyright 2015 Karl Isenberg

Licensed under the Apache License Version 2.0 (the "License"); you may not use this project except in compliance with the License.

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

About

Example web server with dependency injected controllers

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages