Refactor router and storage

* Split and extract data-logic from application level
* Move storage to DeeSee package
* Move router into internal package
* Fix Makefile
* Fix documentation
* Fix tests
This commit is contained in:
2023-02-08 17:44:58 +00:00
parent 2cfe36590f
commit c60839bcfb
7 changed files with 135 additions and 56 deletions

View File

@@ -3,6 +3,7 @@ package deesee
import (
"encoding/json"
"github.com/eslider/superherohub/pkg/people"
"io"
"os"
"strings"
)
@@ -52,6 +53,12 @@ func (s *Superhero) Has(power string) bool {
return s.SuperPowers.Contains(power)
}
// Decode JSON superhero
func (s *Superhero) Decode(reader io.Reader) (err error) {
err = json.NewDecoder(reader).Decode(s)
return
}
// IsAcceptable checks if the given power is allowed.
func IsAcceptable(power string) bool {
for _, p := range allowedSuperPowers {